WCF friction

May 13th, 2008

Today I spent some time (thank God no more than 15 minutes) tracking down a WCF issue from hell. Every time I made a call to the service I got the following exception:

System.ServiceModel.CommunicationException : The underlying connection was closed: The connection was closed unexpectedly.

This is really helpful, isn’t it? Fortunately there is some tool that helped me out a great deal: Service Trace Viewer Tool (SvcTraceViewer.exe). Turns out that I forgot to place a DataContract attribute on one of my DTO objects.

Why am I too stupid to deduce this from the exception message in the first place?

Jan Van Ryswyck Uncategorized

  1. Sachman Bhatti
    May 14th, 2008 at 11:09 | #1

    Interesting, I will need to look at SvcTraceViewer some more. I use an alternative methodology. On the host, you pass exceptiondetails (host.Description.Behaviors.Find().IncludeExceptionDetailInFaults=true).

    Then I put try catches on the service’s methods (which is why I will explore your method since try catches are expensive), which on cath(Exception ex) throw a FaultException. This will show the actual error that happened on the host within the Client.

  2. Sachman Bhatti
    May 14th, 2008 at 11:11 | #2

    The above Find() has a <ServiceDebugBehavior>

    You need to escape your HTML on these comments instead of just replacing them with an empty string :)

  3. May 14th, 2008 at 12:54 | #3

    Hi,

    I’ve always enable exception details in faults in my development environment. Even with this information it was impossible to track down the issue.

Comments are closed.