0

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

该请求仅拉取项目,因此不应引发错误。谁能看到导致此错误的原因?

4

1 回答 1

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"/>

于 2013-09-17T03:48:55.883 回答