如何为 DataContractJsonSerializer 设置 maxItemsInObjectGraph?
我收到一条错误消息"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."
65536这个数字是从哪里来的。DataContractJsonSerializer的文档说默认值为 Int32.MaxValue。
我试图在行为配置中设置它:
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp />
<dataContractJsonSerializer maxItemsInObjectGraph="500000"/>
</behavior>
</endpointBehaviors>
但我收到如下错误:"Invalid element in configuration. The extension name 'dataContractJsonSerializer' is not registered in the collection at system.serviceModel/extensions/behaviorExtensions."
将行为更改<dataContractSerializer maxItemsInObjectGraph="500000"/>
为没有错误但不会更改值(这不足为奇,因为我没有使用 dataContractSerializer)
客户端是使用 ChannelFactory 创建的,因此我无法使用此处描述的 ServiceBehavior 属性