Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Internationalization / November 2006

Tip: Looking for answers? Try searching our database.

Satellites not found for manually loaded assemblies

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jan - 07 Sep 2006 05:28 GMT
Hi,
my application loads assemblies with sub features by Assembly.LoadFrom,
depending on what features user chooses to run.

Each assembly needs to be localized. I'm using satellite resource assemblies
in subfolders. But the satellites are not found by program and defaults are
used. FUSLOGVW shows that they are searched only in appbase and private path
of the main application but the sub assemblies are not directly there.

Is it somehow possible to use the standard resource lookup in this way or do
I have to load also resource assemblies with Assembly.LoadFrom and forget
help of framework ?
I don't want to modify .config of the main application, nothing is known
about the sub assemblies in advance.

Thanks,
Jan
Aldo Donetti [MS] - 12 Oct 2006 23:07 GMT
Hi Jan,
I have tried and in my test the proper resources were loaded for the sub features' assemblies, regardless if they were in a different folder.
Are you just testing the resource loading by setting the CurrentUICulture on the main application? In this case, the CurrentUICulture does not propagate to different threads or child apps you might load with
LoadFrom and might be the reason why the sub features' resources are not loaded.

thanks,
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: AcbSNgFJF2ifpAhkTAqzB4wtfvmExg==
[quoted text clipped - 36 lines]
| Thanks,
| Jan
Aldo Donetti [MS] - 12 Oct 2006 23:34 GMT
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
appropriately. So I'm not sure what's happening in your case.

From the main assembly I have invoked the sub DLL as follows

           Thread.CurrentThread.CurrentUICulture = new CultureInfo("it");

           Assembly c = Assembly.LoadFrom(@"C:\Test\D\D\bin\Debug\D.dll");
           Object o = c.CreateInstance("D.Class1", true);
           MethodInfo m = c.GetType("D.Class1").GetMethods()[0];
           Object o2 = m.Invoke(o,null);

the main assembly is in a different location than the sub DLL and they both load their appropriate resources from their respective locations (the sub DLL loads its Italian resources)

Aldo

-- This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| X-Tomcat-ID: 548411376
| References: <206E86AC-3BFD-43D8-AF6B-3ADFEE5DAA5B@microsoft.com>
[quoted text clipped - 64 lines]
| | Thanks,
| | Jan
Jan - 13 Oct 2006 11:21 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.