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:
- Enable tracing in WCF through the web.config
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log.svclog"></add>
- Run the application and trigger the error
- Open the log file (c:\log.svclog)
- Microsoft Service Trace Viewer will open up
- Navigate to the activity that caused the error
- 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.