“An existing connection was forcibly closed by the remote host” error in WCF service

That was an interesting one. There was only one method in the service that was causing that. On stackoverflow there were several pointers, but all of them were pretty useless.

It turned out that its all about iheritance of [DataContract]. I had a simple service that was returning an object:

From there there was another object that was inheriting from this one:

The WCF service was suppose return type Message

Although MessageWithId is of type Message it was throwing this error. I am not entirely sure why yet. I suppose there is one more field to be serialized which was confusing.

Leave Comment

Your email address will not be published.

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box