Microsoft JScript runtime error: Unhandled Error in Silverlight Application Code: 4004 Category Mana

Posted by SheoNarayan under Error and Solution on 3/1/2011 | Points: 10 | Views : 8709 | Status : [Administrator] | Replies : 2

I was getting following error when I was trying to connect the WCF RIA Services using XAML.

Microsoft JScript runtime error: Unhandled Error in Silverlight Application 
Code: 4004
Category: ManagedRuntimeError
Message: System.ServiceModel.DomainServices.Client.DomainException: An error occurred while loading data through the 'MyMethodNameQuery' query on DomainContext of type 'MyContext' and the error was not handled. If this error is expected, then you must handle the LoadedData event on the DomainSource and call LoadedDataEventArgs.MarkErrorAsHandled() to avoid this exception.

Load operation failed for query 'MyMethodNameQuery'. The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'. ---> System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'MyMethodNameQuery'. The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.
--- End of inner exception stack trace ---
at System.Windows.Controls.DomainDataSource.RaiseLoadedData(LoadedDataEventArgs e)
at System.Windows.Controls.DomainDataSource.MyContext_Loaded(LoadedDataEventArgs e, LoadContext loadContext)
at System.Windows.Controls.DomainDataSource.LoadData_Callback(LoadOperation loadOperation)
at System.ServiceModel.DomainServices.Client.LoadOperation.<>c__DisplayClass4`1.<Create>b__0(LoadOperation`1 arg)
at System.ServiceModel.DomainServices.Client.LoadOperation`1.InvokeCompleteAction()
at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error)
at System.ServiceModel.DomainServices.Client.LoadOperation.Complete(Exception error)
at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
at System.ServiceModel.DomainServices.Client.MyContext.<>c__DisplayClass1b.<Load>b__17(Object )


Solution:

If you investigate this error, you will notice that it is asking for the OrderBy method, so I added OrderBy method into the MyMethodNameQuery method (along with the Entity layer property) and I resolved this error.

public IQueryable<PersonalDetail> MyMethodNameQuery()
{
return this.ObjectContext.MyTableNames.OrderBy(p => p.FirstName);
}


Hope this will be helpful.

Thanks!

Regards,
Sheo Narayan
http://www.dotnetfunda.com



Responses

Posted by: Gsolvers on: 3/6/2011 [Member] Starter | Points: 25

Up
0
Down
Cool Info

Best Regards,

VG
www.TeacherJi.com

SheoNarayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/6/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Thanks sheo for the info!!!

Thanks
Karthik
www.f5Debug.net

SheoNarayan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response