Silverlight 4 RIA datacontext error if I return less than 2 records
Hey there, I am clueless in what is causing this but I get an error when my ria service if less than 2 items are been returned, everything works ok if I have 2 or more records been returned.
My domain data source looks like this:
<riaCont开发者_如何转开发rols:DomainDataSource
AutoLoad="True"
x:Name="dsEmployee"
LoadedData="dsEmployee_LoadedData"
QueryName="GetEmployees">
<riaControls:DomainDataSource.DomainContext>
<my:TestDomainContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
which is been bound to a listbox like this:
<ListBox x:Name="lstEmployees"
ItemsSource="{Binding ElementName=dsEmployee, Path=Data}"
However when I run the application I get this error:
System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetEmployees'. Unexpected end of file. Following elements are not closed: IsEnabled, Employee, RootResults, GetEmployeesResult, GetEmployeesResponse. ---> System.Xml.XmlException: Unexpected end of file. Following elements are not closed: IsEnabled, Employee, RootResults, GetEmployeesResult, GetEmployeesResponse.
at System.ServiceModel.DomainServices.Client.WebDomainClient`1.EndQueryCore(IAsyncResult asyncResult)
at System.ServiceModel.DomainServices.Client.DomainClient.EndQuery(IAsyncResult asyncResult)
at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
Has anyone had the same problem? am I doing something wrong here?
This looks like a problem with async server validation failing because it doesn't have enough time to complete. I don't think it is due to anything you did wrong.
There is some discussion of the issue here and some workarounds. Are you using System.Web, if so it sounds like that should not be used on client side code. http://jeffhandley.com/archive/2010/05/26/asyncvalidation-again.aspx
精彩评论