We have a wcf service, that expects to return a huge XML data. It worked ok in testing, but in production it failed with error
"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."
The MSDN article about dataContractSerializer xml configuration element correctly describes maxItemsInObjectGraph attribute default as 65536, but documentation for of the
DataContractSerializer.MaxItemsInObjectGraph property and DataContractJsonSerializer.MaxItemsInObjectGraph Property
are talking about Int32.MaxValue, which causes confusion, in particular because Google shows properties articles before configuration articles.
When we changed the value in WCF service configuration, it didn't help, because the similar change must be ALSO done on client.
There are similar posts:
I had forgot to place this setting in my client app.config file.
It seems that DataContractJsonSerializer.MaxItemsInObjectGraph has actual default 65536, because there is no
configuration for JSON serializer
, but it complains about the limit.
I believe that MS should clarify the properties documentation re default limit and make more specific error messages to distinguish server side and client side errors.
<dataContractSerializer maxItemsInObjectGraph="..." />
posted @ Sunday, October 28, 2012 1:02 PM