Wonderfully Ambiguous WCF Exception

[1 minute read]

Ah, ambiguous exceptions. You dazzle me with your mysterious wiles. Let me count the myriad ways this could have been precipitated…

CommunicationException: The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.

When I came across this exception yesterday, I knew immediately that the problem couldn’t be due to a contract mismatch because I was invoking same service call in a loop and it worked fine - repeatedly - just a few milliseconds prior to encountering the exception. Googling the error produced a lengthy list of possible causes; it took me more time than I would have preferred to work my way down to message size issues. So this post is really just an FYI to future Googlers: If you get this exception, and your messages are potentially quite large, I’d recommend using the configuration settings described here. In my case, at least, it solved the issue immediately.


Note 4/22/2016: The link above is dead and it doesn’t look like it’s ever coming back. :( Sorry!