Today I had a strange issue with my WCF service. I was getting an error in the wcftestclient after I made a change to a method and published it. The odd part is there was no "exception" information at all. Everything was null, but I did have a stacktrace that ended with:
System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood ...
I googled this problem only to find lots of people having this issue but no one offered up the real cause, and I had to discover it myself. The reason is so simple it made me feel pretty dumb but on the flip side, I've managed to work with WCF for this long without making this mistake so ... there is that.
Turns out I simply WASN'T catching an exception. WCF can not raise an exception past the service boundary of course. I think for grins I actually tried to serialize an exception once and it wasn't pretty, but anyway ... to resolve this, I simply wrote an Error object that has everything I need about the exception and added it to my response object that the service method returns. If an exception occurs, I capture the information into the Error object and make sure my WCF service returns the response regardless. On the client side you simply have to check the error object to see if its' not null, and react appropriately. This is 101 stuff but I thought I'd mention it just in case it may help someone.
If anyone reading this knows of a slicker way, please post a comment with a link to further reading!
j
1e0e757d-ac64-4b1a-ab16-e2bd234bcd82|0|.0