Search code examples
c#.netwcfserializationservicebehavior

Wcf ignore MaxItemsInObjectGraph value


Our WCF service has the following exception:

Maximum number of items that can be serialized or deserialized in an object graph is '32767'. Change the object graph or increase the MaxItemsInObjectGraph quota.

We change the config to:

  <behavior name="large">
      <dataContractSerializer maxItemsInObjectGraph="214783647"/>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
  </behavior>

But no change.

In debug mode when the service host is open the value of the DataContractSerializer is 214783647 and the exception is still occur.

Changing the value programmaticly doesn't help.

Add an attribute of ServiceBehavior on the service doesn't help.

Change the machine.config like here - doesn't help.

Any ideas? Thanks.


Solution

  • Thanks to my college the problem solved with removing ReferencePreservingDataContractFormat attribute, we think it's because this attribute create it's own DataContractSerializer that ignore the configuration.

    More details