Tips using Fault Contract

When we are using Fault Contracts, We would be having in the Catch block as

catch (Exception ex)
{
MySampleFault fault = new MySampleFault();
fault.Reason = "Error Message is " + ex.Message.ToString();
throw new FaultException< MySampleFault >(fault);
}

But at the throw, an error is displayed "The creator of this fault did not specify a reason".

On checking various options, the error goes only when you rewrite it as

throw new FaultException< MySampleFault >(fault, new FaultReason(ex.Message.ToString()));

Cheers!!!

Comments

Popular posts from this blog

Jesus - God Thinks of you.

ASP.NET 4.0 Feature - URL Routing

Tips on JQuery Intellisense in VS 2008