Indigo Errors Perplexing

I was writing a very simple WCF service. Nothing fancy – just returning an array of structs via TCP, just like 3 others already implemented. Started testing, stepped through the server code, returned the value from the service interface, then WHAM – a big scary exception:

System.ServiceModel.CommunicationObjectAbortedException
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue.

Inner Exception:
System.Net.SocketException
An existing connection was forcibly closed by the remote host

This rather scary error message is not very helpful. Was it because of a timeout? (Unlikely, as it happened immediately). Underlying network resource issue? Happens too predictably. Error processing your message? What does that mean, anyway? WHAT error processing my message? And anyway, the inner SocketException seems to imply that it’s a network error, not a message error.

But of course it is. WCF didn’t really point me towards it, but it seems I had forgotten to mark my struct as a [DataContract] and its members as [DataMember]s. No contract, nothing to serialize, no message.

Perfectly understandable, once you know what’s going on. Totally perplexing until you do.

Now let’s give this entry some Googlejuice so people who are experiencing this problem can find it:
WCF, Indigo, CommunicationObjectAbortedException,  SocketException, DataContract.
There. That should do it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.