views:

32

answers:

1

Good afternoon,

I am running into a curious problem with WCF and IntelliTrace. I have an application that I'm testing using a locally-hosted WCF endpoint (the development server built into VS2010) using the basicHttpBinding. The application has been running normally: no exceptions are are making their way to the app and all of the WCF calls are returning data.

On a lark, I decided to take a look at the IntelliTrace output and noticed that my first call to WCF throws two exceptiosn:

Exception:Thrown: "No connection could be made because the target machine actively refused it" (System.Net.Sockets.SocketException)
A System.Net.Sockets.SocketException was thrown: "No connection could be made because the target machine actively refused it"
Exception:Caught: "No connection could be made because the target machine actively refused it" (System.Net.Sockets.SocketException)
A System.Net.Sockets.SocketException was caught: "No connection could be made because the target machine actively refused it"

I've reduced the application to a trivial use case:

    ServiceClient client = new ServiceClient();
    string[] output = client.LegacyCheck("username");
    Console.WriteLine(output[0]);
    Console.WriteLine(client.GetData(65));

And I get the same behavior. The second call has no exception associated with it.

I'm very puzzled. If the connection is being refused, then why does the exception not make it up to the application? And why would it success after 2 failed tries?

Any help is appreciated!

+1  A: 

For what it's worth, I've noticed this behavior too with my IronPython/WPF applications. I've eventually realized that Intellitrace is simply showing you ALL of the exceptions that are raised and caught during normal operation, even if its part of a BCL or other library.

Of course, you only need to worry about unhandled exceptions (after they break your execution, you'll usually see those in IntelliTrace as a long chain of Thrown: Caught: Thrown: Caught: .... all the way down to Thrown: which will be the last line as the exception was not caught.

What I'm willing to bet is that the WCF code try's a couple of things first, catches the SocketExceptions, and then continues on its merry way. You wouldn't ever see this, but for IntelliTrace :)

Aphex