The formatter threw an exception while trying to deserialize the message

I got this error when programming in dot net 3.5 using WCF:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:parameter. The InnerException message was 'There was an error deserializing the object of type XXXXXXXX. 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.'.  Please see InnerException for more details.

Solution:
Find the immediate window in vs2008 and checkout the length of the string by using the length function.
estimate and assign the MaxStringContentLenth to more than the length of the string
in the WCF configuration editor.

MaxStringContentLenth  = Y megabytes * 1024 * 1024.

 

Published Tuesday, March 17, 2009 4:08 AM by darenhan
Powered by Community Server (Commercial Edition), by Telligent Systems