How to set maxItemsInObjectGraph for DataContractJsonSerializer?
I get an 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."
Where the number 65536 comes from. The documentation for the DataContractJsonSerializer says the default is Int32.MaxValue.
I tried to set it in the behavior configuration:
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp />
<dataContractJsonSerializer maxItemsInObjectGraph="500000"/>
</behavior>
</endpointBehaviors>
but I get an error: "Invalid element in configuration. The extension name 'dataContractJsonSerializer' is not registered in the collection at system.serviceModel/extensions/behaviorExtensions."
Changing the behavior to <dataContractSerializer maxItemsInObjectGraph="500000"/>does not give an error, but does not change the value (which is not surprising, since I do not use dataContractSerializer)
The client is created with ChannelFactory, so I cannot use the ServiceBehavior attribute, as described here here
source
share