CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Apr 2005
    Posts
    172

    C# and resource files

    Hello,

    I have an application which we want to be able to localize relatively easy. That is why I am using resouce files.

    I am however experiencing the following issue:

    The name of the assembly is xxx.Web

    I have 2 resource files called xxx.resx and
    xxx.resx

    In my application's pre-build events I have

    resgen xxx.resx
    resgen xxx.es-ES.resx


    which generates the two resource files

    xxx.es-ES.resources
    xxx.resources

    Also when I build the application I get a folder under the Bin folder named es-ES since that is one of the cultures.


    So far so good. When I run my code though I get the following exception:

    MissingManifestResourceException

    Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "xxx.resources" was correctly embedded or linked into assembly "xxx" at compile time, or that all the satellite assemblies required are loadable and fully signed.


    Here is my code:

    since this is an MVC application in the Global.asax I have then following
    Code:
     private void SetLocalization()
            {
                ////For now this is hard coded but in the future when more languages are introduced
                ////the language setting will be read from a config. file.
                string strCulture = "es-ES";
                CultureInfo objCI = new CultureInfo(strCulture);
                Thread.CurrentThread.CurrentCulture = objCI;
                Thread.CurrentThread.CurrentUICulture = objCI;
            }

    Then I have a helper function
    Code:
     public static string GetResourceMessage(this HtmlHelper helper,string messageName)
            {
                ResourceManager rm = new ResourceManager("xxx.strings", 
                Assembly.Load("xxx.Web"));
              
                return rm.GetString(messageName);
            }

    when the program tries to execute the GetSTring() that's when the exceptino is raised.

    What am I missing????


    Thanks very much in advance

    Susan
    Last edited by Suzi167; June 26th, 2009 at 10:34 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured