Hi Aldo,
thanks for answer.
I need to read localized strings. The dll project contains embedded
resource.resx with English texts and resource.cs.resx with Czech ones. Build
creates localized *.resources.dll in subfolder "cs".
I try to load strings in the program like this:
System.Threading.Thread.CurrentThread.CurrentUICulture = new
System.Globalization.CultureInfo("cs");
System.Resources.ResourceManager resourceManager = new
System.Resources.ResourceManager("namespace.resource",
this.GetType().Assembly);
string txt = resourceManager.GetString("stringID");
FUSLOGVW shows that the resource manager searches for the cs resource dll in
subforlers of the main application, not at the dll location.
Should I do it in different way ?
Regards,
Jan
> Hi again Jan,
> during a second test I have noticed that the assembly that you load with LoadFrom is actually getting the same Thread.CurrentThread.CurrentUICulture object as the main application and it's loading resources
[quoted text clipped - 84 lines]
> | | Thanks,
> | | Jan
Aldo Donetti [MS] - 09 Nov 2006 03:25 GMT
Sorry for the delay Jan - you must have figured it out by now, but if not, you can manually load resources by either:
1. manually locate and load the DLL with LoadFrom, then use a resourceManager on that, as in
string p = Application.StartupPath;
Assembly c = Assembly.LoadFrom(p + @"\cs\LoadResourcesManually.resources.dll");
System.Resources.ResourceManager rm = new System.Resources.ResourceManager("LoadResourcesManually.Form1.cs", c);
string txt = rm.GetString("label1.Text");
note that in this case you don't need to set a UICulture because you're loading the DLL containing resources manually
2. do what the Windows Forms' code-behind does and use the ComponentResourceManager
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("cs");
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
string txt = resources.GetString("label1.Text");
3. use the "old" way
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("cs");
System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(Form1));
string txt = rm.GetString("label1.Text");
HTH
Aldo
-- This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Thread-Topic: Satellites not found for manually loaded assemblies
| thread-index: AcbusUhsYyfUXZiBTqux93bt0FnAOQ==
[quoted text clipped - 131 lines]
| > | | Thanks,
| > | | Jan