3
Answers

Maximum number of items that can be serialized or deserialized in an object graph is '65536'

Ask a question
Ciaran O Neill

Ciaran O Neill

15y
14.7k
1
Hi,

I'm trying to debug a problem that's occurring when sending large amounts of data over WCF.  The error message from the System.ServiceModel.CommunicationException that's being thrown is:
"There was an error while trying to serialize parameter http://tempuri.org/:batch. The InnerException message was '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. '.  Please see InnerException for more details."

I've tried changing everything I could find in both the service web.config and the client app.config, but nothing is working for me.  My relevant sections from web.config are:
<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_ISyncEndpoint" maxBufferPoolSize="10485760" maxReceivedMessageSize="2147483647">
          <readerQuotas maxStringContentLength="8192" maxArrayLength="20971520" />
          <reliableSession enabled="true" ordered="true" />
          <security mode="None">
            <transport clientCredentialType="None"  />
            <message establishSecurityContext="false" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="SyncWebService.SyncEndpoint" behaviorConfiguration="WSHttpBinding_ISyncEndpoint_Behaviour">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:3923/SyncEndpoint.svc"/>
          </baseAddresses>
        </host>
        <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ISyncEndpoint" contract="SyncWebService.ISyncEndpoint" />
      </service>
    </services>
    <behaviors>
      <!--<endpointBehaviors>
        <behavior name="WSHttpBinding_ISyncEndpoint_Behaviour">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 2147483647
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </endpointBehaviors>-->
     
      <serviceBehaviors>
        <behavior name="WSHttpBinding_ISyncEndpoint_Behaviour">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>


The sections from the app.config are:
<system.serviceModel>
    <bindings>
      <!-- Http binding settings -->
      <wsHttpBinding>
        <binding name="WSHttpBinding_ISyncEndpoint" closeTimeout="05:01:00" openTimeout="05:01:00" receiveTimeout="05:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <!--<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />-->
          <readerQuotas maxStringContentLength="8192" maxArrayLength="20971520" />
          <reliableSession ordered="true" inactivityTimeout="05:50:00" enabled="true" />
          <security mode="None">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <!-- communication channel to the SyncWebService remote web service (refered to as SyncEndpoint.svc) -->
      <!--<endpoint address="http://localhost:3923/SyncEndpoint.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ISyncEndpoint" contract="SyncWebService.ISyncEndpoint" name="WSHttpBinding_ISyncEndpoint" />-->
      <endpoint address="http://localhost:3923/SyncEndpoint.svc" binding="wsHttpBinding"
                bindingConfiguration="WSHttpBinding_ISyncEndpoint" contract="SyncWebService.ISyncEndpoint" name="WSHttpBinding_ISyncEndpoint"
                behaviorConfiguration="WSHttpBinding_ISyncEndpoint_Behaviour" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="WSHttpBinding_ISyncEndpoint_Behaviour">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/> <!--2147483647-->
        </behavior>
      </endpointBehaviors>
      <!--<serviceBehaviors>
        <behavior name="WSHttpBinding_ISyncEndpoint_Behaviour">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>-->
    </behaviors>
  </system.serviceModel>

This is causing me a big problem, so if anyone has an idea it would be much appreciated.

TIA,
Ciaran O'Neill


Answers (3)