尝试访问WCF服务时出现以下错误。
'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值相同的异常。
我按照在Link上找到的说明进行操作,但是没有运气。
这是我在WCF服务的Web.Config上配置的内容。
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl="" />
<serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</serviceBehaviors>
</behaviors>
这是客户端的app.config中的内容:
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior >
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</endpointBehaviors>
</behaviors>
最后,我在WCF服务本身上具有以下属性:
[ServiceBehavior(MaxItemsInObjectGraph = 2147483646, IncludeExceptionDetailInFaults = true)]
尽管进行了上述配置,但我仍然收到有关65536值的异常投诉。为什么应用程序没有使用这些设置中的任何一个?还有其他需要设置的地方吗?
最佳答案
您在正确的轨道上!
您要做的就是为行为添加一个名称
<behavior name="MyBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
然后在端点上添加
<endpoint .... behaviorConfiguration="MyBehavior"/>
关于wcf-configuration - WCF MaxItemsInObjectGraph设置不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17622408/