The creator of this fault did not specify a Reason

Mité picture Mité · Jun 26, 2012 · Viewed 11.1k times · Source

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

Answer

CodeCaster picture CodeCaster · Jun 26, 2012

When this fails I get the exception

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

catch (FaultException<ValidationFault> ex)