"The creator of this fault did not specify a Reason" Exception

Posted by Michael Kniskern on Stack Overflow See other posts from Stack Overflow or by Michael Kniskern
Published on 2008-12-04T17:49:58Z Indexed on 2010/04/14 9:43 UTC
Read the original article Hit count: 1431

Filed under:
|
|
|

I have the following code in WCF service to throw a custom fault based on certain situations. I am getting a "The creator of this fault did not specify a Reason" exception. What am I doing wrong?

//source code
if(!DidNotPass)
{
    InvalidRoutingCodeFault fault = new InvalidRoutingCodeFault("Invalid Routing Code - No Approval Started");
    throw new FaultException<InvalidRoutingCodeFault>(fault);
}

//operation contract
[OperationContract]
[FaultContract(typeof(InvalidRoutingCodeFault))]
bool MyMethod();

//data contract
[DataContract(Namespace="http://myuri.org/Simple")]
public class InvalidRoutingCodeFault
{
    private string m_ErrorMessage = string.Empty;

    public InvalidRoutingCodeFault(string message)
    {
        this.m_ErrorMessage = message;
    }

    [DataMember]
    public string ErrorMessage
    {
        get { return this.m_ErrorMessage; }
        set { this.m_ErrorMessage = value; }
    }
}

© Stack Overflow or respective owner

Related posts about wcf

Related posts about faults