views:

17

answers:

2

Hi

My goal is simply to show a language-specific errormessage for a Required-Annotation:

[Required(ErrorMessageResourceName = "LastNameRequired", ErrorMessageResourceType = typeof(ValidationMessage))]

LastNameRequired is the key of the string in the resourcefile, ValidationMessage is the type generated by the resource file. The resourcefile is in the same project and namespace.

I changed the Access Modifier of the resourcefile to public. Build Action is on Embedded Resource.

The actual behaviour is, that it doesn't show an errormessage, it even doesn't show an error for that attribute. If I remove the ErrorMessage*-Attribute from the Attribute, all works fine.

[Required]
A: 

When you use a generated resource class, check if it has public properties. Resources has only internal properties as default, so you must select the Resource file (.resx) in Solution Explorer and in window Properties replace Custom Tool field value "ResXFileCodeGenerator" with "PublicResXFileCodeGenerator" then rebuild solution...

Ardman
Thank you, but I did that already. It didn't change anything.
Daniel
A: 

I found the solution. The problem occured, because I didn't used the default-namespaces. I had to add a -element in the project file for the linked resources.

Daniel