G
Guest
I am having a problem localizing a .Net 2.0 class library. This library is
called in a Windows.Forms application. My operating system language is en-US.
In the class library, I have a file, Resources.resx, which is set to be
embedded in the library's dll. This is working properly. I can get the
default resources using this code:
ResourceManager rm = new ResourceManager("MyLib.Resources",
Assembly.GetExecutingAssembly());
return rm.GetString("MyString");
This works. The second line does return the default language value for
MyString.
The problem is, the following line also returns the default language value
for MyString:
return rm.GetString("MyString", new CultureInfo("es-MX"));
I created the es-MX satellite assembly by placing a copy of Resources.resx
in the bin/Debug/es-MX folder under my project code and renaming it to
Resources.es-MX.resx. I changed the value of several resources for test and
then compiled Resources.es-MX.resx using:
resgen Resources.es-MX.resx Resources.es-MX.resources
and linked the satellite assembly using:
al /t:lib /embed:Resources.es-MX.resources /culture:es-MX
/out:MyLib.Resources.dll
When I run the application the class library, MyLib.dll, and the folder
es-MX, containing MyLib.Resources.dll, are copied to the bin/debug folder of
my application. The result is that in the debug folder of the application is
MyApp.exe and MyLib.dll and a folder named es-MX. In the folder es-MX is the
file MyLib.Resources.dll.
The application calls several string properties of objects defined in MyLib.
Each of these properties returns the default language text rather than the
es-MX text even though I am passing the "es-MX" culture as defined in the
line above.
When I debug the application and step through to the line where the resource
string is being returned, I can call Assembly.GetExecutingAssembly() in the
immediate window and see that the current assembly is, as I had hoped, MyLib
and not MyApp.
Thanks in advance for any help.
Dale
called in a Windows.Forms application. My operating system language is en-US.
In the class library, I have a file, Resources.resx, which is set to be
embedded in the library's dll. This is working properly. I can get the
default resources using this code:
ResourceManager rm = new ResourceManager("MyLib.Resources",
Assembly.GetExecutingAssembly());
return rm.GetString("MyString");
This works. The second line does return the default language value for
MyString.
The problem is, the following line also returns the default language value
for MyString:
return rm.GetString("MyString", new CultureInfo("es-MX"));
I created the es-MX satellite assembly by placing a copy of Resources.resx
in the bin/Debug/es-MX folder under my project code and renaming it to
Resources.es-MX.resx. I changed the value of several resources for test and
then compiled Resources.es-MX.resx using:
resgen Resources.es-MX.resx Resources.es-MX.resources
and linked the satellite assembly using:
al /t:lib /embed:Resources.es-MX.resources /culture:es-MX
/out:MyLib.Resources.dll
When I run the application the class library, MyLib.dll, and the folder
es-MX, containing MyLib.Resources.dll, are copied to the bin/debug folder of
my application. The result is that in the debug folder of the application is
MyApp.exe and MyLib.dll and a folder named es-MX. In the folder es-MX is the
file MyLib.Resources.dll.
The application calls several string properties of objects defined in MyLib.
Each of these properties returns the default language text rather than the
es-MX text even though I am passing the "es-MX" culture as defined in the
line above.
When I debug the application and step through to the line where the resource
string is being returned, I can call Assembly.GetExecutingAssembly() in the
immediate window and see that the current assembly is, as I had hoped, MyLib
and not MyApp.
Thanks in advance for any help.
Dale