使用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>
再次運行,一切正常。