WCF Debugging

October 23, 2015

WCF is a good product in so many respects; but error reporting isn’t one of them. Whilst trying to get a WCF service to work, I encountered this error:

Exception thrown: ‘System.ServiceModel.CommunicationException’ in mscorlib.dll

Additional information: An error occurred while receiving the HTTP response to http://localhost:17065/Service1.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.



The following will produce a surprisingly useful diagnosis file.

To add diagnostics, edit the web.config of the service and add:

      <source name="System.ServiceModel" switchValue="Warning" propagateActivity="true">
          <add name="xml"/>

      <source name="TraceSource" switchValue="Warning, ActivityTracing" propagateActivity="true">
          <add name="xml"/>

      <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\\trc.svclog"/>

And then:

    <diagnostics wmiProviderEnabled="true">

Now replicate the error and have a look in the directory you pointed the initializeData to (in my case c:\trc.svclog). Providing you’ve used the correct extension, double clicking the file should give you something like this:


Profile picture

A blog about one man's journey through code… and some pictures of the Peak District

© Paul Michaels 2024