Pages

Tuesday 6 March 2012

Exception: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.

In WCF, if there are large data to return, 
we get the following exception

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.

To resolve this,
we need to add the following settings in config file:

<behaviors>
<endpointBehaviors>
<behavior name="ExampleBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</endpointBehaviors>
<
serviceBehaviors>
</behaviors> 

and in binding of WCF Service, we need to add behaviorConfiguration attribute

<endpoint address="exampleaddress" binding="basicHttpBinding" 
bindingConfiguration="BasicHttpBinding_IExampleService"
contract="ExampleService.IExampleService"
name="BasicHttpBinding_IExampleService"
behaviorConfiguration="ExampleBehavior"/>

No comments:

Post a Comment