title: Maximum array length quota
body: <p>I'm writing a small WCF/WPF app to resize images but WCF is giving me grief when I try to send an image of size 28K to my service from the client. The service works fine when I send it smaller images. I immediately assumed that this was a configuration issue and I've trawled the web looking at posts regarding the MaxArrayLength property in my binding configuration. Ive upped the limits on these settings on both the client and server to the maximum 2147483647 but still I get the following 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://mywebsite.com/services/servicecontracts/2009/01:OriginalImage" rel="noreferrer">http://mywebsite.com/services/servicecontracts/2009/01:OriginalImage</a>. 
    The InnerException message was 'There was an error deserializing the object of type System.Drawing.Image. 
    The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.'.  Please see InnerException for more details.</p>
  </blockquote>
  
  <p>I've made my client and server configs the same and they look like the following:
  Server:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;netTcpBinding&gt;
              &lt;binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
                  openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                  transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                  hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                  maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
                  maxReceivedMessageSize="2147483647"&gt;
                  &lt;readerQuotas maxDepth="32"
                                maxStringContentLength="2147483647"
                                maxArrayLength="2147483647"
                                maxBytesPerRead="2147483647"
                                maxNameTableCharCount="2147483647" /&gt;
                  &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt;
                  &lt;security mode="Transport"&gt;
                      &lt;transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /&gt;
                      &lt;message clientCredentialType="Windows" /&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/netTcpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
          &lt;serviceBehaviors&gt;
              &lt;behavior name="ServiceBehavior"&gt;
                  &lt;serviceMetadata httpGetEnabled="true" /&gt;
                  &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
              &lt;/behavior&gt;
          &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;services&gt;
          &lt;service name="LogoResizer.WCF.ServiceTypes.ImageResizerService" behaviorConfiguration="ServiceBehavior"&gt;
              &lt;host&gt;
                  &lt;baseAddresses&gt;
                      &lt;add baseAddress="http://localhost:900/mex/"/&gt;
                      &lt;add baseAddress="net.tcp://localhost:9000/" /&gt;
                  &lt;/baseAddresses&gt;
              &lt;/host&gt;
              &lt;endpoint binding="netTcpBinding" contract="LogoResizer.WCF.ServiceContracts.IImageResizerService" /&gt;
              &lt;endpoint  address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;
          &lt;/service&gt;
      &lt;/services&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>and my client config looks like:</p>
  
  <pre><code> &lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;netTcpBinding&gt;
              &lt;binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
                  openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                  transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                  hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                  maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
                  maxReceivedMessageSize="2147483647"&gt;
                  &lt;readerQuotas maxDepth="32" 
                                maxStringContentLength="2147483647"
                                maxArrayLength="2147483647" 
                                maxBytesPerRead="2147483647" 
                                maxNameTableCharCount="2147483647" /&gt;
                  &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt;
                  &lt;security mode="Transport"&gt;
                      &lt;transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /&gt;
                      &lt;message clientCredentialType="Windows" /&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/netTcpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
          &lt;endpoint address="net.tcp://localhost:9000/" binding="netTcpBinding"
              bindingConfiguration="NetTcpBinding_ImageResizerServiceContract"
              contract="ImageResizerService.ImageResizerServiceContract"
              name="NetTcpBinding_ImageResizerServiceContract"&gt;
              &lt;identity&gt;
                  &lt;userPrincipalName value="me@domain.com" /&gt;
              &lt;/identity&gt;
          &lt;/endpoint&gt;
      &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>It seems no matter what I set these values to I still get an error saying wcf cannot serialize my file because its greater than 16384. Any ideas?</p>
  
  <p><strong>Update:</strong> the email address in the userPrincipalName tag has been altered for my privacy</p>