I have a button that updates product information and I started seeing this error:
Microsoft JScript runtime error: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.Exception: Submit error is not handled!
at Telerik.Windows.Data.QueryableDomainServiceCollectionView`1.OnDomainContextSubmittCompleted(SubmitOperation submitOperation)
at System.ServiceModel.DomainServices.Client.SubmitOperation.InvokeCompleteAction()
at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error)
at System.ServiceModel.DomainServices.Client.SubmitOperation.Complete(OperationErrorStatus errorStatus)
at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClassb.<SubmitChanges>b__3(Object )
I'm a Silverlight novice, so I'm not sure what it's telling me.
Here is the code for the button click and Domain Data Source:
private
void
ddsSummaryLoadedData(
object
sender,
Telerik.Windows.Controls.DomainServices.LoadedDataEventArgs e )
{
try
{
//Data is now loaded so lets fill our controls.
if
( e.HasError ==
false
)
{
//Get our record object.
Summary sum = ( Summary )e.Entities.First();
CurrentSummary = sum;
//Save for later.
WR_IDText.Text = sum.WorkRequest;
WR_SuffixText.Text = sum.WorkRequestSuffix;
ProductVersionText.Text = sum.ProductVersion;
if
( sum.ApprovalDateTime.HasValue ==
true
)
{
//ApprovalDatePicker.CurrentDateTimeText = sum.ApprovalDateTime.Value.ToShortDateString();
ApprovalDatePicker.SelectedDate = ( System.DateTime )sum.ApprovalDateTime;
}
if
( sum.ReportDateTime.HasValue ==
true
)
{
//ReportDatePicker.CurrentDateTimeText = sum.ReportDateTime.Value.ToShortDateString();
ReportDatePicker.SelectedDate = ( System.DateTime )sum.ReportDateTime;
}
//Clear.
sum =
null
;
}
else
{
//Display error.
ErrorWindow.CreateNew( e.Error,
StackTracePolicy.OnlyWhenDebuggingOrRunningLocally );
}
}
catch
( Exception ex )
{
//Display error.
ErrorWindow.CreateNew( ex, StackTracePolicy.OnlyWhenDebuggingOrRunningLocally );
}
}
private
void
ddsSummaryIterationsLoadedData(
object
sender,
Telerik.Windows.Controls.DomainServices.LoadedDataEventArgs e )
{
try
{
//Data is now loaded.
if
( e.HasError ==
false
)
{
IterationTitleLabel.Text =
"Iterations - "
+ e.TotalEntityCount.ToString()
+
" rows"
;
}
else
{
//Display error.
ErrorWindow.CreateNew( e.Error,
StackTracePolicy.OnlyWhenDebuggingOrRunningLocally );
}
}
catch
( Exception ex )
{
//Display error.
ErrorWindow.CreateNew( ex,
StackTracePolicy.OnlyWhenDebuggingOrRunningLocally );
}
}
private
void
ddsSummaryIterations_SubmittedChanges(
object
sender,
DomainServiceSubmittedChangesEventArgs e )
{
try
{
if
( e.HasError ==
false
)
//Make sure there wasn't any errors.
{
if
( e.Cancelled ==
false
)
//Make sure it wasn't cancelled and it's complete.
{
//Refresh controls.
ddsSummaryIterations.Load();
DeleteIterationButton.IsEnabled =
false
;
}
}
else
{
//Display error.
ErrorWindow.CreateNew( e.Error,
StackTracePolicy.OnlyWhenDebuggingOrRunningLocally );
}
}
catch
( Exception ex )
{
//Display error.
ErrorWindow.CreateNew( ex,
StackTracePolicy.OnlyWhenDebuggingOrRunningLocally );
}
}
private
void
SaveSummaryButtonClick(
object
sender, RoutedEventArgs e )
{
try
{
//Make sure we aren't already submitting and or loading data.
if
( ddsSummary.IsSubmittingChanges ==
false
& ddsSummary.IsLoadingData ==
false
&
IsUnique ==
true
)
{
//Make changes to entity.
CurrentSummary.WorkRequest = WR_IDText.Text;
CurrentSummary.WorkRequestSuffix = WR_SuffixText.Text;
CurrentSummary.ProductVersion = ProductVersionText.Text;
CurrentSummary.HistoricalInfo_LUser = 0;
CurrentSummary.HistoricalInfo_LDateTime = DateTime.Now;
CurrentSummary.HistoricalInfo_LAction =
"U"
;
if
( ApprovalDatePicker.SelectedDate !=
null
)
CurrentSummary.ApprovalDateTime = ApprovalDatePicker.SelectedDate;
else
CurrentSummary.ApprovalDateTime =
null
;
if
( ReportDatePicker.SelectedDate !=
null
)
CurrentSummary.ReportDateTime = ReportDatePicker.SelectedDate;
else
CurrentSummary.ReportDateTime =
null
;
//Send for an update.
ddsSummary.SubmitChanges();
}
}
catch
( Exception ex )
{
//Display error.
ErrorWindow.CreateNew( ex, StackTracePolicy.OnlyWhenDebuggingOrRunningLocally );
}
}
private
void
OnSubmitCompleted( SubmitOperation e )
{
try
{
if
( e.HasError ==
false
)
//Make sure there wasn't any errors.
{
if
( e.IsCanceled ==
false
& e.IsComplete ==
true
)
//Make sure it wasn't cancelled and it's complete.
{
//Refresh controls.
ddsSummaryIterations.QueryParameters[ 0 ].Value = CurrentSummary.Id;
ddsSummaryIterations.Load();
}
}
else
{
//Display error.
ErrorWindow.CreateNew( e.Error,
StackTracePolicy.OnlyWhenDebuggingOrRunningLocally );
}
}
catch
( Exception ex )
{
//Display error.
ErrorWindow.CreateNew( ex, StackTracePolicy.OnlyWhenDebuggingOrRunningLocally );
}
}
And here is the code from the Update section of the domain service file:
#region Update Data Methods
public
void
UpdateSummary( Summary currentSummary )
{
this
.ObjectContext.Summaries.AttachAsModified( currentSummary,
this
.ChangeSet.GetOriginal( currentSummary ) );
}
#endregion
Any advice?