An unhandled exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll

user1269016 picture user1269016 · Feb 11, 2014 · Viewed 31.4k times · Source

I am getting the following error when calling a method in a webservice, not developed by me.

An unhandled exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll

It does not only happen on my local dev machine, but also on a client's server when the software is deployed.

I am currently using Visual Studio 2010.

Answer

user1269016 picture user1269016 · Feb 12, 2014

After catching the CommunicationException, and looking at the InnerException, I found the following details: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. The solution for this problem was to add the following to my config file.

<bindings>
  <basicHttpBinding>
    <binding name="R2MSBulkUploadSoap" allowCookies="true"
             maxReceivedMessageSize="20000000"
             maxBufferSize="20000000"
             maxBufferPoolSize="20000000">
      <readerQuotas maxDepth="32"
           maxArrayLength="200000000"
           maxStringContentLength="200000000"/>
    </binding>
  </basicHttpBinding>
</bindings>

I found this solution from here