02 August, 2013

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

Error:
"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."

Solution:

Try to change config file:

Add <readerQuotas> and set maxArrayLength="2147483647"

<binding name="WSHttpBinding_IBackup"
         closeTimeout="1:00:00"
         maxBufferPoolSize="2147483647"
         maxBufferSize="2147483647"
         maxReceivedMessageSize="2147483647"
         openTimeout="1:00:00"
         receiveTimeout="1:00:00"
         sendTimeout="1:00:00"
         transferMode="Streamed">
 
  <readerQuotas
    maxArrayLength="2147483647"
    maxBytesPerRead="2147483647"
    maxDepth="2147483647"
    maxNameTableCharCount="2147483647"
    maxStringContentLength="2147483647" />
 
  <!--if any issue then try this one-->
  <!--<textMessageEncoding messageVersion="Soap11" 
                       maxReadPoolSize="2147483647" 
                       maxWritePoolSize="2147483647">
    <readerQuotas
      maxArrayLength="2147483647"
      maxBytesPerRead="2147483647"
      maxDepth="2147483647"
      maxNameTableCharCount="2147483647"
      maxStringContentLength="2147483647" />
  </textMessageEncoding>-->
 
</binding>
 
If you have same issue then try following solution.
Reason:-
  • My service is simply ignoring my binding “basicHttp_ServiceName” and it’s always taking default binding
  • Reason is
    • My configuration service name does not match with service name in Service Host
    • The name I given is "ServiceName" where it has to be "XYZ.ServiceName"
    • E.g.
      <%@ ServiceHost Language="C#" 
                      Debug="true" 
                      Service="XYZ.ServiceName" 
                      CodeBehind="ServiceName.svc.cs" %>
      
      
Fix :-
  • Right click your “.svc” file and choose “View Markup”
  • Copy the Service name and paste it in your service name
  • Now my Service configuration looks below
  • E.g
     <services>
        <service name="XYZ.ServiceName">
     
        </service>
      </services>

1 comment: