WCF samples
Hosting and Consuming WCF service
System.ServiceModel.FaultException`1 was unhandled by user code
So far so good. Then from the client application side you simply need to catch the FaultException error type as you normally do and retrive the message return by the Servcie SOAP message as follow:
Client side
catch (FaultException MyError) { string msg = Error.Detail.Message; MessageBox.Show (msg); wcfclient.Close(); }
And that’s it. You then receive the error message send from your server, inside your client application.. Hmmm this is what I was expecting but it was not behaving as expected. I spend days to cross check my code and verify impementation to get the exception correctly thrown but when runnig my application my service was stoping at the time it was throwing the exception (throw fe). The error return from that execution was something strange like :
“System.ServiceModel.FaultException`1 was unhandled by user code“
After a lot of research I find out the solution on a post mentionning that it was due to some setting of debugging scenario of my VS environement, which make my code execution stop at each exception with not really logic message wich was giving a lot of confusion.
To remove this behaviour it was advise to uncheck the 2 following options from the Tools->Option menu of IDE:
Hoping this post will save you a lot of research time. Once again, every thing works until you hit the point that gives you nightmare 🙂
Recent Comments