Connect with me
Search
Twitter Feed
Navigation
« Visual Studio 2008 - Join the dark side *UPDATED* | Main | Dynamic Data - Formatting Values »
Monday
Feb162009

Debug cryptic WCF errors with WCF Tracing and the Microsoft Service Trace Viewer

While working on a project involving Silverlight and WCF REST I ran into some errors that didn’t give me much insight into the actual problem.

The error I got was:

System.Net.WebException: The remote server return an error: NotFound

The usual culprit is the message returning data greater than the default MaxMessageSize of 64K. In my case I was sure my message less than that.

I followed the following procedure to debug this error:

  1. Enable tracing in WCF through the web.config
    <system.diagnostics>
    <sources>
    <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
    <listeners>
    <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log.svclog"></add>
    </listeners>
    </source>
    </sources>
    </system.diagnostics>
  1. Run the application and trigger the error
  2. Open the log file (c:\log.svclog)
  3. Microsoft Service Trace Viewer will open up
  4. Navigate to the activity that caused the error
  5. See the stack trace

In my case the error was a DateTime issue. One of my date fields was not set and hence defaults to 0001-01-01 and hence couldn’t be serialized when it returns to the client.

In most cases if you get this type of error it usually is a serialization error.

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>