loading strings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Da Lick!

    loading strings

    Hello,

    Got strings.resx included in my assmebly as the default language neutral
    collection.

    ResourceManager res=new ResourceManager ("strings",
    Assembly.GetExe cutingAssembly( ));

    string test=res.GetStr ing("TestString ");

    TestString exists in the resource file. The compiler message window
    seems to indicate thsat the strings are compiled and included in the
    assembly but I'm getting unhandled exception
    System.Resource s.MissingManife stResourceExcep tion

    Could not find any resources appropriate for the specified culture in
    the given assembly. Make sure "strings.resour ces" was correctly linked
    or embedded into assembly.

    Help!!!
  • Kai Brinkmann [MSFT]

    #2
    Re: loading strings

    You need to use the fully qualified name of the resource file in the
    ResourceManager constructor.
    --
    Kai Brinkmann [MSFT]

    Please do not send e-mail directly to this alias. This alias is for
    newsgroup purposes only.
    This posting is provided "AS IS" with no warranties, and confers no rights.

    "Phil Da Lick!" <phil_the_lick@ NOSPAMhotmail.c om> wrote in message
    news:eHFDU6HXFH A.2520@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hello,
    >
    > Got strings.resx included in my assmebly as the default language neutral
    > collection.
    >
    > ResourceManager res=new ResourceManager ("strings",
    > Assembly.GetExe cutingAssembly( ));
    >
    > string test=res.GetStr ing("TestString ");
    >
    > TestString exists in the resource file. The compiler message window seems
    > to indicate thsat the strings are compiled and included in the assembly
    > but I'm getting unhandled exception
    > System.Resource s.MissingManife stResourceExcep tion
    >
    > Could not find any resources appropriate for the specified culture in the
    > given assembly. Make sure "strings.resour ces" was correctly linked or
    > embedded into assembly.
    >
    > Help!!![/color]


    Comment

    • Phil Da Lick!

      #3
      Re: loading strings

      Kai Brinkmann [MSFT] wrote:[color=blue]
      > You need to use the fully qualified name of the resource file in the
      > ResourceManager constructor.[/color]

      what resource file? does it not work the same way as VC++ where the
      resources are compiled into the assembly? I've just added the resources
      in a resx to the assembly in the prroject view.

      Comment

      • Kai Brinkmann [MSFT]

        #4
        Re: loading strings

        Yes, the base resources are compiled into the assembly. All language
        resource files end up in satellite assemblies. If you're using VS, this will
        be done automatically as long as you observe the proper naming conventions.

        For example, let's assume you created a resource file AppResources.re sx in
        your project and your namespace is MyNamespace.MyA pp.
        In this case, the ctor for your ResourceManager should look like this:

        ResourceManager rm = new ResourceManager ("MyNamespace.M yApp.AppResourc es",
        Assembly.GetExe cutingAssembly( ));

        Note the fully qualified resource name!

        AppResources.re sx is compiled to AppResources.re sources (you can do this
        manually using resgen) and embedded in your core assembly (MyApp.exe). You
        can create localized resource files like this:

        AppResources.fr-FR.resx // French (France) resources
        AppResources.de-DE.resx // German (Germany) resources
        AppResources.ja-JP.resx // Japanese (Japan) resources

        These resources will also be compiled to their appropriate resources files
        and embedded in satellite assemblies named MyApp.resources .dll. These
        assemblies will end up in directories named after the culture (fr-FR, de-DE,
        ja-JP) underneath your main application directory. At run-time, the resource
        manager will attempt to find appropriate resources for the selected
        CurrentUICultur e. There is a fallback mechanism if no resources can be
        found, and as a last resort the resources embedded in the main assembly will
        be used (i.e. the resources in the base resource file AppResources.re sx).

        I hope this helps.
        --
        Kai Brinkmann [MSFT]

        Please do not send e-mail directly to this alias. This alias is for
        newsgroup purposes only.
        This posting is provided "AS IS" with no warranties, and confers no rights.

        "Phil Da Lick!" <phil_the_lick@ NOSPAMhotmail.c om> wrote in message
        news:ujL7PITXFH A.2288@TK2MSFTN GP14.phx.gbl...[color=blue]
        > Kai Brinkmann [MSFT] wrote:[color=green]
        >> You need to use the fully qualified name of the resource file in the
        >> ResourceManager constructor.[/color]
        >
        > what resource file? does it not work the same way as VC++ where the
        > resources are compiled into the assembly? I've just added the resources in
        > a resx to the assembly in the prroject view.[/color]


        Comment

        • Phil Da Lick!

          #5
          Re: loading strings

          Kai Brinkmann [MSFT] wrote:[color=blue]
          > Yes, the base resources are compiled into the assembly. All language
          > resource files end up in satellite assemblies. If you're using VS, this will
          > be done automatically as long as you observe the proper naming conventions.
          >
          > For example, let's assume you created a resource file AppResources.re sx in
          > your project and your namespace is MyNamespace.MyA pp.
          > In this case, the ctor for your ResourceManager should look like this:
          >
          > ResourceManager rm = new ResourceManager ("MyNamespace.M yApp.AppResourc es",
          > Assembly.GetExe cutingAssembly( ));
          >
          > Note the fully qualified resource name![/color]

          Just what I needed, thanks.

          [color=blue]
          > AppResources.re sx is compiled to AppResources.re sources (you can do this
          > manually using resgen) and embedded in your core assembly (MyApp.exe). You
          > can create localized resource files like this:
          >
          > AppResources.fr-FR.resx // French (France) resources
          > AppResources.de-DE.resx // German (Germany) resources
          > AppResources.ja-JP.resx // Japanese (Japan) resources[/color]

          So can I also just include these into the assembly in the project view
          and VS will take care of them automatically?

          Comment

          Working...