WCF - Win App "The maximum length of the content line length (8192) was exceeded when reading XML data."

I am having some problem when implementing a web service through WCF. Although I pass the value in the WCF method from the client application as a string (xml), we get an error

The formatter threw an exception while trying to deserialize the message: an error occurred while trying to deserialize the http://tempuri.org/:XmlEntity parameter.

InnerException message was

'Error deserializing an object of type System.String. The maximum length of the content line length (8192) was exceeded when reading XML data. This quota can be increased by changing the MaxStringContentLength property of the XmlDictionaryReaderQuotas Object when creating an XML reader. Line 249, position 19. '.

I tried to change the maxStringContentLength value in the client.configuration file of the client, but the error remains the same. Please try to find a solution as soon as possible.

+8
wcf
source share
4 answers

Ashish, Darin means you must create basicHttpBinding to override and increase the value of maxStringContentLength to 2147483647. Can you confirm if you configured the endpoint to use the same bitting with the bindingConfiguration attribute. For example, you created a binding like this,

 <basicHttpBinding> <binding name="HandleLargeMessage" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> 

You can configure the endpoint to use the above binding configuration like this, (note the bindingConfiguration attribute)

 <endpoint address="....." binding="basicHttpBinding" bindingConfiguration="HandleLargeMessage" contract="xxx" /> 

Can you confirm that you have already done this? it is very likely that this does not seem to be the case.

If you have already done this and want to confirm whether it uses WCF traces for the service and client application at a detailed level and check the actions in the Construct Host on sevice and the Construct channel in the client application.

+12
source share

Try increasing this value both on the server and on the client:

 <binding name="myBinding" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> 
+7
source share

As always with WCF, this is a software alternative to increase MaxStringContentLength.

 BasicHttpBinding binding = new BasicHttpBinding(); binding.ReaderQuotas.MaxStringContentLength = 2147483647 host.AddServiceEndpoint(contract, binding, address); 
+1
source share

The size of maxStringContentLength should be increased. But you should not blindly increase all values ​​to this number. For example, maxDepth refers to nesting levels in XML, and it is better to leave it as default.

-one
source share

All Articles