Search code examples
wcfvalidation-application-bl

The creator of this fault did not specify a Reason


I have set validation attributes in the model of my WCF service

[MinLength(6, ErrorMessage = "Password should be at least 6 characters long")]
public String Password { get; set; }

When this fails I get the exception in the title instead of the error message that I specified in the attribute. I am using the Validation Application Block for WCF.

The method definition is like this:

[OperationContract]
[FaultContract(typeof(ValidationFault))]
User updateUser(User user);

Can someone tell my what I am doing wrong?

Thanks


Solution

  • When this fails I get the exception

    You should specify the type of Fault you expect, so use

    catch (FaultException<ValidationFault> ex)