WCF Error: CommunicationException was unhandled


CommunicationException was unhandled

An error occurred while receiving the HTTP response to http://localhost:8732/Design_Time_Addresses/WCFService/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.


If you get an error something similar to the above error message when you attempt to consume a WCF Service, there are many reasons for you to get this error, but let me explain how I resolved it and maybe it will be helpful to you.

First I realized that the error message above is not at all specific for me to understand and fix it, so I had to enable WCF Tracing to be able to have detailed and specific information on the Error. If you need to know how to Enable WCF Tracing, you can refer to my post on that here.

After Enabling WCF Tracing, I was able to view the Trace log using the SvcTraceViewer.exe tool that Microsoft provides and figured out that the specific error I was getting was this:

Cannot serialize the DataTable. DataTable name is not set.

And to resolve the issue I had to assign a Name to the DataTable before it get sent back by the WCF Service. I used the TableName property of the DataTable to assign the Table Name as follows:

     DataTable dt = new DataTable();
           dt.TableName = "MyTableName";


That solved the problem for me.

Hope it helps solve your problem too!