Welcome on Kweetix Technical Blog

Tuesday, August 30, 2011

WCF Services with large data : Increasing maxStringContentLength value has no effect

The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'SendStatistic'. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

This message occurs even if you have increased the value of MaxStringContentLength.

Solution : Create a "default" binding section in the basicHttpBinding section of the server config file.

<binding>
<readerQuotas maxDepth="32" maxStringContentLength="102400" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>


For customBinding, this problem can be solved by adding an attribute maxReceivedMessageSize="524288" to httpTransport directive : 

<httpTransport maxReceivedMessageSize="524288"/>


3 comments:

  1. You just saved my day.
    Thanks.
    Jan.

    ReplyDelete
  2. You just saved my day too.
    Thanks.

    Vincent

    ReplyDelete
  3. Great tip. Setting the maxStringContentLength (in a custom binding) worked on some platforms but not all, so applying a default binding was the solution.
    Thanks.

    Boris

    ReplyDelete