title: Exception: Maximum number of items that can be serialized or deserialized in an object graph is '65536'
body: <p>I looked at others posts, but I didn't find solution to my problem.</p>
  
  <p>My service config file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/&gt;
    &lt;/configSections&gt;
    &lt;appSettings&gt;
      ...
    &lt;/appSettings&gt;
    &lt;log4net&gt;
      ...
    &lt;/log4net&gt;
    &lt;system.serviceModel&gt;
      &lt;protocolMapping&gt;
        &lt;add scheme="http" binding="wsDualHttpBinding"/&gt;
      &lt;/protocolMapping&gt;
      &lt;services&gt;
        &lt;service name="Service1" behaviorConfiguration="Service1Behavior"&gt;
          &lt;endpoint address="" binding="netTcpBinding" contract="IService1" bindingConfiguration="NetTcpBinding_IService1"&gt;
            &lt;identity&gt;
              &lt;dns value="localhost"/&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="/mex" binding="mexTcpBinding" contract="IMetadataExchange"/&gt;
        &lt;/service&gt;
        &lt;service name="Service2" behaviorConfiguration="Service2Behavior"&gt;
          &lt;endpoint address="" binding="wsHttpBinding" contract="IService2" bindingConfiguration="WSHttpBinding_IService2"&gt;
            &lt;identity&gt;
              &lt;dns value="localhost" /&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;bindings&gt;
        &lt;wsHttpBinding&gt;
          &lt;binding name="WSHttpBinding_IService2" receiveTimeout="00:00:10"
            sendTimeout="00:00:10" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
            useDefaultWebProxy="false"&gt;
            &lt;reliableSession ordered="true" inactivityTimeout="00:00:11" /&gt;
            &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
              maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt;
            &lt;security mode="None" /&gt;
          &lt;/binding&gt;
        &lt;/wsHttpBinding&gt;
        &lt;netTcpBinding&gt;
          &lt;binding name="NetTcpBinding_IService1" receiveTimeout="00:00:20"
            sendTimeout="00:00:20" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"&gt;
            &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
              maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt;
            &lt;reliableSession ordered="true" inactivityTimeout="00:00:11" /&gt;
            &lt;security mode="None" /&gt;
          &lt;/binding&gt;
        &lt;/netTcpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="Service1Behavior"&gt;
            &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
            &lt;serviceMetadata httpGetEnabled="False"/&gt;
  
            &lt;serviceDebug includeExceptionDetailInFaults="True"/&gt;
            &lt;serviceThrottling maxConcurrentCalls="100"
                      maxConcurrentInstances="100"
                      maxConcurrentSessions="100" /&gt;
          &lt;/behavior&gt;
          &lt;behavior name="Service2Behavior"&gt;
            &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
            &lt;serviceMetadata httpGetEnabled="True"/&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="True"/&gt;
            &lt;serviceThrottling maxConcurrentCalls="100"
                      maxConcurrentInstances="100"
                      maxConcurrentSessions="100"  /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
    &lt;connectionStrings&gt;
      ...
    &lt;/connectionStrings&gt;
    &lt;system.diagnostics&gt;
      &lt;sources&gt;
        &lt;source name="System.ServiceModel" switchValue="Error,ActivityTracing"
          propagateActivity="true"&gt;
          &lt;listeners&gt;
            ...
          &lt;/listeners&gt;
        &lt;/source&gt;
      &lt;/sources&gt;
    &lt;/system.diagnostics&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/&gt;
    &lt;/startup&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>My client config file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
      &lt;configSections&gt;
          ...
      &lt;/configSections&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;netTcpBinding&gt;
                  &lt;binding name="NetTcpBinding_IService1" closeTimeout="00:00:15"
                      openTimeout="00:00:15" receiveTimeout="00:00:40" sendTimeout="00:00:40"
                      transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                      hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                      maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
                      maxConnections="10" maxReceivedMessageSize="2147483647"&gt;
                      &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                          maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt;
                      &lt;reliableSession ordered="true" inactivityTimeout="00:10:00"
                          enabled="false" /&gt;
                      &lt;security mode="None"&gt;
                          &lt;transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /&gt;
                          &lt;message clientCredentialType="Windows" /&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/netTcpBinding&gt;
              &lt;wsHttpBinding&gt;
                  &lt;binding name="WSHttpBinding_IService2" closeTimeout="00:00:15"
                      openTimeout="00:00:15" receiveTimeout="00:00:25" sendTimeout="00:00:15"
                      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                      maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                      messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="false"&gt;
                      &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                          maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt;
                      &lt;reliableSession ordered="true" inactivityTimeout="00:00:11" /&gt;
                      &lt;security mode="None"&gt;
                          &lt;transport realm="" /&gt;
                          &lt;message clientCredentialType="Windows" negotiateServiceCredential="true" /&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/wsHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
              &lt;endpoint address="http://.../Design_Time_Addresses/Service2/"
                  binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService2"
                  contract="Service2Reference.IService2"
                  name="WSHttpBinding_IService2"  behaviorConfiguration="serviceBehaviorConfiguration"&gt;
                  &lt;identity&gt;
                      &lt;dns value="localhost" /&gt;
                  &lt;/identity&gt;
              &lt;/endpoint&gt;
              &lt;endpoint address="net.tcp://.../Design_Time_Addresses/Service1/"
                  binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IService1"
                  contract="Service1Reference.IService1" name="NetTcpBinding_IService1"
                  behaviorConfiguration="serviceBehaviorConfiguration"&gt;
                  &lt;identity&gt;
                      &lt;dns value="localhost" /&gt;
                  &lt;/identity&gt;
              &lt;/endpoint&gt;
          &lt;/client&gt;
        &lt;behaviors&gt;
          &lt;endpointBehaviors&gt;
            &lt;behavior name="serviceBehaviorConfiguration"&gt;
              &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
            &lt;/behavior&gt;
          &lt;/endpointBehaviors&gt;
        &lt;/behaviors&gt;
      &lt;/system.serviceModel&gt;
      &lt;userSettings&gt;
          ...
      &lt;/userSettings&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Why I still get exception:</p>
  
  <pre><code>The formatter threw an exception while trying to deserialize the message: 
  There was an error while trying to deserialize parameter http://tempuri.org/:GetData.
  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. '.
  </code></pre>
  
  <p>Is seems to ignore <code>&lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;</code> in both <code>App.config</code> files. Why?</p>