Link to home
Start Free TrialLog in
Avatar of Simonc74
Simonc74Flag for United States of America

asked on

WCF - The maximum array length quota (16384) has been exceeded while reading XML data

I created a wcf service application which fails when uploading large amounts of data (max 5-10 MB) for the following reason:

"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:data. The InnerException message was 'There was an error deserializing the object of type System.Collections.Generic.List`1 [[..., myService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]. 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. Line 1, position...'.

This is how my binding looks on the client app.config file:

<basicHttpBinding>
        <binding name="BasicHttpBinding_IUploadService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536000" maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32000" maxStringContentLength="8192000" maxArrayLength="16384000"
            maxBytesPerRead="4096000" maxNameTableCharCount="16384000" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>


I'm using the binding for my endpoint configuration;

    <client>
      <endpoint address="http://localhost:52980/UploadService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUploadService"
        contract="myService.IUploadService" name="BasicHttpBinding_IUploadService" />
    </client>


I've updated the server side configuration although when I update the service reference it still reverts back to the default maxArrayLength, etc.

I can upload small amounts of data successfully so I know it's not a bug in the code.

Furthermore the application doesn't send a request to the service when uploading large amounts of data which suggests an issue on the client side?
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Can you post your complete server side config file?
If you have defined your server binding configuration, then  I think you are missing service binding section  in the server config file, check:
http://scorpiotek.com/blog/?p=393
http://stackoverflow.com/questions/464707/maximum-array-length-quota
Avatar of Simonc74

ASKER

Posting the complete server side config file...
Web.config
The reader quotas between client and server config files does not match.
Both binding configurations must be the same.
ASKER CERTIFIED SOLUTION
Avatar of Simonc74
Simonc74
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is the solution I used in order to solve the problem I was having. While the other posts were helpful they failed to resolve my problem. I had already tried the suggested solutions prior to the posts being added