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

Posted on 2012-08-20
Last Modified: 2012-09-11
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 The InnerException message was 'There was an error deserializing the object of type System.Collections.Generic.List`1 [[..., myService, Version=, 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:

        <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"
          <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" />

I'm using the binding for my endpoint configuration;

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

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?
Question by:Simonc74
    LVL 35

    Expert Comment

    by:Miguel Oz
    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:

    Author Comment

    Posting the complete server side config file...
    LVL 35

    Expert Comment

    by:Miguel Oz
    The reader quotas between client and server config files does not match.
    Both binding configurations must be the same.

    Accepted Solution

    I ended up re-creating the wcf service aplication.

    I updated the web.config using the WCF Service Configuration Editor (right click on web.config > "Edit WCF Cnofiguration") I would advise using the configuration editor if experiencing the same problem.

    Author Closing Comment

    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

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now