How to set resource strings in resx file RRS feed

  • Question

  • User-209105085 posted

    I’m validating my WCF request object’s parameter using DataAnnotation. This is working fine and no problems there.

    I want to store my error messages into resx file. According to my understanding the default resource provider will use the Current thread’s UI culture to determine which resource string to retrieve.

    Do I need to name the .resx file in certain way so that resource provider will know which file to use for particular culture? If yes, what is the naming convention?

    For example, if you see the code below ErrorMessageResourceType is set to ServiceResourceStrings which is the class created by .Net for .resx file, now if I have one more .resx file for different language say “es-MX”, then it will have different class name. I don’t see the .resx file itself stored any culture code


    [Required(ErrorMessageResourceName = "NameRequired", ErrorMessageResourceType = typeof(ServiceResourceStrings))]


    public string Name





    Wednesday, May 9, 2012 1:00 PM

All replies

  • User-209105085 posted

    so on MSDN http://msdn.microsoft.com/en-us/library/ms247246.aspx it says

    1. In the Name box, type a name for the resource file and then click Add.

    2. Type key names and values for each resource that you need in your application, and then save the file.

    3. To create resource files for additional languages, copy the file in Solution Explorer or in Windows Explorer, and then rename it using one of the following patterns:

      • For global resource files:



        so i setup my file names as "ServiceResourceStrings.resx" and "ServiceResourceStrings.fr-CA.resx" and  then just for testing purpose i set my web.config file to  <globalization uiCulture="fr-CA"/> but the resource provider always retreives resources from ServiceResourceStrings.resx, WHY?

    Wednesday, May 9, 2012 2:58 PM
  • User1080340250 posted

    Thorough tutorial here

    Thursday, July 26, 2012 1:40 PM