前不久出现的WCF一个错误 —— MaxStringContentLength & MaxReceivedMessageSize

具体错误信息如下:

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

 

 

WCF配置节:

<bindings> <netTcpBinding> <binding name="NewBinding0" maxReceivedMessageSize="6553600"> <readerQuotas maxStringContentLength="6553600" /> </binding> </netTcpBinding> </bindings> 
如果没有设置<readerQuotas maxStringContentLength="6553600" />,则默认值为readerQuotas的默认最大长度为8192. 因此当长度超过8192时,会抛出文章开头提到的错误。

同样需要另外设定binding的maxReceivedMessageSize,否则会抛出System.ServiceModel.CommunicationException异常。

 

 

你可能感兴趣的:(前不久出现的WCF一个错误 —— MaxStringContentLength & MaxReceivedMessageSize)