wcf序列化大对象时报错:读取 XML 数据时,超出最大

错误为:

访问服务异常:格式化程序尝试对消息反序列化时引发异常: 尝试对参数 http://tempuri.org/ 进行反序列化时出
错: request。InnerException 消息是“反序列化对象 属于类型 Fast.Infrastructure.WCFService.DataTransferObject.BaseRequest 时出现错误。读取 XML 数据时,超出最大
字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,可增加此配额
 
解决办法:
 
修改wcf客户端的配置
<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="NewBinding0" maxReceivedMessageSize="65536000">
          <readerQuotas maxStringContentLength="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8732/FAST.WCFService.Endpoint/FastService/"
        binding="wsHttpBinding"
        bindingConfiguration="NewBinding0" contract="Fast.Infrastructure.WCFService.Endpoint.IFastWCFService"
        name="fastEndpoint" />
    </client>
  </system.serviceModel>
 
增加此binding 并设置readerQuotas 的maxStringContentLength的值 
修改完后记得在endpoint 上加上此bingding:bindingConfiguration="NewBinding0"
原文地址:https://www.cnblogs.com/gaogaolater/p/3558977.html