I have a very strange situation. I have a large set of records to return as a List from a WCF service. If I return the set as a DataTable, everything works fine. There are about 19,000 records in the set. If I return the set as a List (where T is a DataContract) it errors out and closes connection upon returning any set longer than 10922 records. I would think it was a problem with my data except another person has reported the exact same problem with a limit of 10922 records. Has anyone else encountered this problem, and if so how did you solve it?
We actually have this problem at work. We try to send a lot of data through a WCF web service. We get cutout at something like 20,000 records so we ended up breaking up the data and doing a number of web service calls. Can you do something similar? Break up the records into smaller chunks and then merge them on the other end?
Check your endpoints' maxReceivedMessageSize on both client and server.
We encountered the same problem.
From the service trace log we could retrieve the following exception:
Error while trying to serialize parameter []. Maximum numberError while trying to serialize parameter []. Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota.
After changing the dataContractSerializer key with parameter maxItemsInObjectGraph everything was running smoothly even with millions of records (on condition that you changed the maxReceivedMessageSize accordingly).
These changes have to be made in the web.config and the app.config in the following way:
web.config:
<behaviors>
<serviceBehaviors>
<behavior name="WasteWatcher.TestService.ServiceImplementation.TestService_Behavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
app.config:
<behaviors>
<endpointBehaviors>
<behavior name="SerializerBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
Don't forget to add the parameter behaviorConfiguration="SerializerBehavior" to the endpoint key:
<endpoint address="http://localhost:9542/TestService.Host/TestService.svc"
binding="customBinding" bindingConfiguration="DefaultEndpoint"
contract="WasteWatcher.TestService.Test.Client.TestServiceProxy.TestServiceContract"
name="DefaultEndpoint" behaviorConfiguration="SerializerBehavior">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
Best regards
Markus Rohlof