LP Pinsonneault blog's

Windows 8, Windows Phone, ...

NAVIGATION - SEARCH

Debugging WCF Web Services

Currently I'm working on a Silverlight project, that retrieve some data from the server using WCF. Sometimes when there is some error the message return to the Silverlight application is : The remote server return an error: Not Found.

image

This pretty strange because I've flag the set the configuration <serviceDebug includeExceptionDetailInFaults="true" /> and the error doesn’t show up properly. And worst when you do step by step debugging, i won’t show you the error, and the application automatically raise the Completed event of that method you called.

So how can we know the exact error message?

There is a simple way to do that. Implement the System.Diagnostic in the .config file of the WCF application. In my case, it’s in the web.config of the web site hosting the services.

<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>

This will generate a file with some trace that you will be able to analyse with the Microsoft Service Trace Viewer. The application will show you in red where there is some error.

image

When we click on the line with the error, the right pane is updated to show more detail information regarding the selected trace. Again you will see in red where there is some error.

image

We then select the current error and the bottom pane will show you the exact error message that you will need.

image

 

 

This error is very simple to fix … but when you get the proper error message!

Hope this will help some of you.


Regards,
LP