Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I am trying to fetch the data through the window service I am getting the following error.
(I am fetching around 10000 records from the database.)

The formatter threw an exception while trying to deserialize the message:
There was an error while trying to deserialize parameter
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.

Please help me.
Updated 13-Sep-10 1:35am
[no name] 13-Sep-10 7:23am    
It would be helpful to see what you are doing.
Dalek Dave 13-Sep-10 7:35am    
Edited for Grammar and Readability.

You need to make sure that the data you return can be serialized by the serializer.
Try reducing the count of records returned to verify that this is the case.

If it is a size issue there are a few things you can try; you can turn up the message payload size on the binding:
<binding name="MyBinding"

Or you can change your application logic to read the records in chunks or pages.
I'd go for the latter if possible because it scales better.

Hope this helps,
Share this answer
The error message is fairly self-explanatory. What does your object graph look like? Do you have nested objects? How large are they? With 10,000 records you probably have a lot of data and it is exceeding the limit of the serializer.
Share this answer
gahlawat 13-Sep-10 7:58am    
i have increase the value also . but still facing this problem

openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00"
allowCookies="false" bypassProxyOnLocal="false"; hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text"; textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true";
readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"
[no name] 13-Sep-10 8:16am    
You still haven't provided details about the objects you are returning form the database and how they are constructed
Make sure that the object is serializable as well as all its parts with the CORRECT version of your classes. What do I mean -- well, you are serializing an object of a class and then you modify the class and then you want to load the object of the original class. This could throw new exceptions not unlike the one that you saw. Second, the size of the serialization needs to be considered, 10k records should not be shocking if you're not using IMAGES and other BLOBS.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900