Topics: Validation Application Block
Jul 24, 2008 at 11:05 AM
I cannot get a validator to retrieve a non-default resource. Always the default resource is being taken.

I added a resource named "Validation.resx" to my project. VS automatically added the ResXFileCodeGenerator for it. I then added a "" and VS did not add the generator. On compilation, a new DE folder is created in the bin/debug directory and using reflector I can see all resources.

On unit-testing I check the CurrentCulture = 'de-AT' and CurrentUICulture = 'de-DE'. but still the default/english resource text is being used.

any ideas?

regards, Tilli
Jul 24, 2008 at 1:32 PM

There's a known issue that causes validators to be cache the first localized message. Can you test trying the "de-DE" culture first?

Jul 24, 2008 at 3:45 PM
hi! my locale is never changed. so it's always as stated above.
Jul 24, 2008 at 4:24 PM


Can you post a repro? How are you specifying validators? What kind of app are you building?

I've just tried with a simple console app using attribute-driven validation and it worked fine. I've defined a Validation resx file and a that generates the satellite assembly just as you describe.

using System;

using System.Linq;

using System.Threading;

using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;


namespace ValidationLocalizationRepro


    class Program


        static void Main(string[] args)


            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-ES");


            var customer = new Customer { Name = "ABCDEF" };

            var results = Microsoft.Practices.EnterpriseLibrary.Validation.Validation.Validate(customer);





    class Customer




            MessageTemplateResourceName = "Message1",

            MessageTemplateResourceType = typeof(Validation))]

        public string Name { get; set; }




Jul 25, 2008 at 7:30 AM
thanks for checking! I basically did exactly as you did. I'll try your sample with my binaries and see if I can repro the problem!

regards, Tilli
Jul 25, 2008 at 10:45 AM

I had similar issues yesterday.
My messagetemplates are cached in the culture of the first user who hits the validators.

You could reset the cache by doing.

Or you could like I did change the source of the ValidationFactory.cs
        public static Validator<T> CreateValidator<T>(bool cacheValidator)
            return CreateValidator<T>(string.Empty, ConfigurationSourceFactory.Create(), cacheValidator);


Jul 25, 2008 at 12:37 PM
thanks! seems the 4.0 source has gotten a bit more complicated. I'll see if I can figure out how to turn caching off