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

3

5

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.

Bywaters answered 11/2, 2014 at 10:19 Comment(1)
When you are talking to another machine somewhere else on the planet, the most basic thing that can go wrong is the failure to communicate. Use the InnerException to find out why. And be sure to enable WCF tracingMesothelium
B
9

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

Bywaters answered 12/2, 2014 at 8:21 Comment(0)
B
0

Look at MSDN there is a quite description what to do:

Robust client and service applications handle CommunicationException objects that may be thrown during communication. There are also two CommunicationException-derived exception types (FaultException and FaultException) that clients also often expect. Therefore, in order to prevent the generic CommunicationException handler from catching these more specific exception types, catch these exceptions prior to handling CommunicationException.

Becalm answered 11/2, 2014 at 10:27 Comment(0)
E
0

For other people with this problem, it can be useful, enable log errors in server WebConfig:

<system.diagnostics>  
    <trace autoflush="true" />  
    <sources>  
            <source name="System.ServiceModel"   
                    switchValue="Information, ActivityTracing"  
                    propagateActivity="true">  
            <listeners>  
               <add name="sdt"   
                   type="System.Diagnostics.XmlWriterTraceListener"   
                   initializeData= "SdrConfigExample.e2e" />  
            </listeners>  
         </source>  
    </sources>  
</system.diagnostics>  

In my case was a serialize error:

How to return a List<object> in WCF

Eck answered 23/7, 2018 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.