title: Passing large amounts of data in an WCF service
body: <p>I've seen this question pop up a few times but with no real definitive answer (as there is most likely none)... I have a WCF service that needs to return approximately 14,000 rows of data from SQL sorted in an List&lt;> based array.</p>
  
  <p>My service config looks like:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
  &lt;bindings&gt;
    &lt;basicHttpBinding&gt;
      &lt;binding name="BasicHttpBinding_IParts" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true"&gt;
        &lt;readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt;
        &lt;security mode="None"&gt;
          &lt;transport clientCredentialType="None" proxyCredentialType="None"
              realm="" /&gt;
          &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
        &lt;/security&gt;
      &lt;/binding&gt;
    &lt;/basicHttpBinding&gt;
  &lt;/bindings&gt;
  &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
  &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior&gt;
        &lt;serviceMetadata httpGetEnabled="true"/&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
        &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  </code></pre>
  
  <p></p>
  
  <p>My client config looks like:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;basicHttpBinding&gt;
              &lt;binding name="BasicHttpBinding_IParts" closeTimeout="00:01:00"
                  openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                  allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                  messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                  useDefaultWebProxy="true"&gt;
                  &lt;readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                      maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt;
                  &lt;security mode="None"&gt;
                      &lt;transport clientCredentialType="None" proxyCredentialType="None"
                          realm="" /&gt;
                      &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
          &lt;endpoint address="http://localhost/RasFuseService/Parts.svc"
              binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IParts"
              contract="MyParts.IParts" name="BasicHttpBinding_IParts" /&gt;
      &lt;/client&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="MyServiceBehavior"&gt;
            &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Something isn't right because i'm getting the error:</p>
  
  <blockquote>
    <p>The formatter threw an exception while trying to deserialize the message: 
        There was an error while trying to deserialize parameter     <a href="http://tempuri.org/:GetSurplusECMResult" rel="nofollow">http://tempuri.org/:GetSurplusECMResult</a>. 
        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.</p>
  </blockquote>
  
  <p>Even though i'm explicitly assigning MaxItemsInObjectGraph with a max int...</p>
  
  <p>I've read about streaming and paging, but is this really too much data to return in a single pass? </p>