WCF.. The dreaded maximum string content exception

Last week I had a famous WCF error message stating that the message string length was too not large enough making it appear to be an issue with the behaviors or bindings being set to default. The error I was receiving was as shown below:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:queryDTO. The InnerException message was ‘There was an error deserializing the object of type Service.UserAnalyticsLibrary.QueryDTO. 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. Line 1, position 19142.’. Please see InnerException for more details.


The portion
“There was an error deserializing the object of type Service.UserAnalyticsLibrary.QueryDTO. The maximum string content length quota (8192) has been exceeded while reading XML data.”

is the key here (or was supposed to be). This turned out after several crapy days to be a red herring. Don’t we all just love those? It actually turned out that the portion that was an issue was the dataserializer itself. Adding this line to the bindings fixed the issue:

One thing to note here is that when you are adding these new properties to change the defaults, YOU MUST GIVE EVERYTHING A NAME. If you do not give your behaviors and bindings a name, the default will be selected regardless of what you enter in the bindings properties.

Happy Coding 🙂

Advertisements

About Gregg Coleman

I am Senior-level Software Engineer working primarily these days with .NET. I have a good working knowledge of ASP.NET MVC, Web Forms, WCF web services and Windows Services. I spend much of my time in the Web Services (SOAP and REST) world in my current job designing and implementing various SOA architectures. I have been in the software engineering industry for about 6 years now and will not now nor ever consider myself an "expert" in programming because there is always so much to learn. My favorite thing about designing software is there are always new emerging technologies and something to learn every day! My current job has me spending much of my job on the bleeding edge of technologies and changing gears all the time, so I'm never bored and always challenged. On my spare time I enjoy weight training, reading and venturing to new places near by. Of course programing and learning new technologies are another hobby of mine.
This entry was posted in ASP.NET, C#, Computer Technology and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s