Error Message from resource file

Topics: Validation Application Block
Apr 15, 2010 at 8:43 PM
Edited Apr 15, 2010 at 10:03 PM

I am trying to use the validation error message from resource file and not able to make it work.

I am using only configuration file (Not the attributes) to validate the object. I have resource file created and there is an entry in that. Here is my config for the property to validate.

<validator lowerBound="1" lowerBoundType="Inclusive" upperBound="4" upperBoundType="Inclusive" negated="false" messageTemplate="" <messageTemplateResourceName="UserMsg_RequestParameterInvalid" messageTemplateResourceType="typeof(Resources)"   tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.StringLengthValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="String Length Validator" />

I am using VAB in service. I am trying to validate the request object in service call and returning the error of validation in the response of the service call.

 What am i doing wrong. Please guide.

Apr 16, 2010 at 1:12 AM

You should set the messageTemplateResourceType attribute to the fully qualified name of the resource file (namespace.classname, namespace).  You can check for that by opening the designer.cs file of the .resx file.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.

Apr 22, 2010 at 5:57 PM
Edited Apr 22, 2010 at 5:58 PM

Thanks for your previous reply and it worked.

Now I want to return a error message from service and the message should be in the users language in the parameter.

I am setting culture in the service exposed method using

System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");

I have my resourec filed named as


But the resource string return from the validation result is always english. Whats could be the posssible error? Thanks for your help.

Apr 23, 2010 at 12:37 AM

You should be setting the CurrentUICulture instead of the CurrentCulture.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.