Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum number of items that can be serialized or deserialized in an object graph... with knowtypes

In a WCF 4.0 service we receive a huge amount of data in a generic list. This list object graph is bigger than the 65536 default limit. We are quite used to it, so we have configured the service for being able to getting those big graphs.

<serviceBehaviors>
    <behavior>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>

With the above chunk of xml config we have avoided the problem in the past with no problem, but now it doesn't work. The only difference is that here we are using KnownTypes in the huge list elements that we are trying to deserialize in the WCF method.

Maybe, am I missing some special configuration for knowntypes?

like image 389
Pablo Castilla Avatar asked Feb 08 '12 10:02

Pablo Castilla


2 Answers

Don't forget to check client configuration.

See similar answers in How to fix MaxItemsInObjectGraph error?

You need to set the MaxItemsInObjectGraph on the dataContractSerializer using a behavior on both the client and service.

and maxItemsInObjectGraph ignored

I had forgot to place this setting in my client app.config file

.

like image 66
Michael Freidgeim Avatar answered Nov 19 '22 09:11

Michael Freidgeim


With reference to http://wcf.codeplex.com/discussions/258278, put the following ServiceBehavior attribute on the class definition as follows:

[ServiceContract]
[ServiceBehavior(MaxItemsInObjectGraph = int.MaxValue)]
public class MaintenanceResource
like image 1
D Barndon Avatar answered Nov 19 '22 09:11

D Barndon