在对象图中可以序列化或反序列化的最大项数是'32767'

时间:2013-09-16 19:14:08

标签: wcf nhibernate web-config

我收到错误: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.

这是我的服务器端和客户端web.config的样子:

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="App" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service name="USMC.Playbook.DataService.PlaybookService">
    <endpoint address="" behaviorConfiguration="LargeQuotaBehavior" binding="basicHttpBinding"
      bindingConfiguration="basicBinding" name="Playbook" contract="USMC.Playbook.DataService.IPlaybookService"/>
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="LargeQuotaBehavior">
      <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="">
      <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceAuthorization impersonateCallerForAllOperations="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<client>
    <endpoint address="http://localhost/AppService.svc" binding="basicHttpBinding" bindingConfiguration="App" contract="AppService.IAppService" name="App"/>
</client>

请求只是拉项目所以它不应该抛出错误。任何人都可以看到导致此错误的原因吗?

1 个答案:

答案 0 :(得分:0)

将此配置放入服务配置

您在配置中遗漏的是服务行为,

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="App" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
          <message clientCredentialType="UserName" algorithmSuite="Default"/>
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <services>
    <service name="USMC.Playbook.DataService.PlaybookService" behaviorConfiguration="SilverlightWCFLargeDataApplication">
      <endpoint address="" behaviorConfiguration="LargeQuotaBehavior" binding="basicHttpBinding"
        bindingConfiguration="basicBinding" name="Playbook" contract="USMC.Playbook.DataService.IPlaybookService"/>
    </service>
  </services>
  <behaviors>
    <endpointBehaviors>
      <behavior name="LargeQuotaBehavior">
        <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
      </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
      <behavior name="SilverlightWCFLargeDataApplication">
        <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
        <serviceAuthorization impersonateCallerForAllOperations="false"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <client>
    <endpoint address="http://localhost/AppService.svc" binding="basicHttpBinding"    bindingConfiguration="App" contract="AppService.IAppService" name="App"/>