1. Back To Blog

WCF Interview questions and answers: -What is the difference between WCF fault exceptions and normal .NET exceptions?

If you throw a normal .NET exception from a WCF service as shown in the below code snippet.

 

throw  new Exception("Divide by zero");

 

Your WCF client will get a very generic error with a message as shown in the below figure. Now this kind of message can be very confusing as it does not pinpoint what exactly the error is.

 

wcf

Generic error in WCF client

 

If you use a raise a fault exception as shown in the below code, your WCF clients will see the complete clear error rather than a generic error as shown previously.

 

throw  new FaultException("Divide by zero");

 

Your WCF client will now see a better error description as shown below.

 

wcf

Better error using Fault Exception

 

You can also buy our book .NET interview question from flipkart by click on

 

You can also watch the below video which answers a very interesting WCF interview question :- "What is one way contract in WCF services?"

 

 

You can visit for more WCF interview question and answer

 

Regards,

 

Click to view more from author's on WCF interview question and answer

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social