27. May 2011 06:24
When you start with WCF, you will certainly need to adjust the limits of the service. By default they are kind of low. So in my case we did. Especially the maxrecievedmessagesize.
Setting up the service, configuring you’re limits and start to use. Sounds really great and simple. But sometimes when you are working with development data and start doing stress tests, you will encounter even more limits. One of these will generate this really nice error:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:GetCountriesResult. The InnerException message was '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. '. Please see InnerException for more details.
What this really means is that the number of objects send through the wire is higher than the default limit or the limit you have specified. To send more large number of records (objects) over the wire you’ll need to adjust the following:
On the server (raise the maxitemsinobjectgraph):
On the client (raise the maxitemsinobjectgraph for the clients endpoint behavior):
The maximum size of the maxItemsInObjectGraph is: 2147483646.
Now you can get those long lists of data and sent it over the wire. Although I strongly believe you should reconsider when a lot of these exceptions occur and split up data in chunks or rethink the way the data is shown to the user.