使用WCF服务的客户端出现maxReceivedMessageSize异常

使用WCF服务的客户端出现maxReceivedMessageSize异常解决方案

    当使用WCF的客户端调取的数据过多时,会出现这个异常。一般情况下,系统默认值是65536,大约容纳100-200条左右的数据。所以建议您在您的项目中,为了避免使用时时期出现这个错误。您应该使用如下解决方案。

    解决方案:在客户端的Config文件中,加入maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"属性。

如图:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ICaseService"  maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
        <binding name="BasicHttpBinding_IEvidenceService"   maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8537/Service/CaseService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICaseService"
        contract="CaseService.ICaseService" name="BasicHttpBinding_ICaseService" />
      <endpoint address="http://localhost:8537/Service/EvidenceService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEvidenceService"
        contract="EvidenceService.IEvidenceService" name="BasicHttpBinding_IEvidenceService" />
</client> </system.serviceModel> </configuration>

再次运行,一切正常。

原文地址:https://www.cnblogs.com/songxingzhu/p/3286708.html