PC Review


Reply
Thread Tools Rate Thread

Loading resources from satellite assemblies of reflection loaded assemblies..

 
 
npthomson@gmail.com
Guest
Posts: n/a
 
      23rd Nov 2006
Hi all,

This could get a bit complicated but I'll try to be as clear as
possible. I've written an application that discovers plugins at
runtime using reflection from a subdirectory of the application, eg:

In the directory the application is installed to:

\application.exe
\plugins\plugin1.dll
\plugins\plugin2.dll

I've successfully generated satellite assemblies for the main
application, these appear as (for example):

\en\application.resource.dll
\fr\application.resource.dll

All is good so far. The plugins also have resources that need to be
localized, I expected their satellite assemblies to be required under:

\plugins\en\plugin1.resource.dll
\plugins\en\plugin2.resource.dll
\plugins\fr\plugin1.resource.dll
\plugins\fr\plugin2.resource.dll

However I find that my the ResourceManager class is trying to load them
from the same location as the application satellite assemblies:

\en\plugin1.resource.dll
\en\plugin2.resource.dll
\fr\plugin1.resource.dll
\fr\plugin2.resource.dll

I include some xml embedded in each plugin assembly so that the
application knows what classes it can create, the following is a
simplification of the loading code (this stuff is in the application
assembly).

FileName = "\plugins\plugin1.dll"; // obviously this isn't hard coded
in the app.
_pluginAssembly = Assembly.LoadFile(FileName);

At this point the XML is loaded, part of this is the name of the
resources that your supposed to pass to the constructor of
ResourceManager. For example assuming the plugin has the namespace
application.plugin1 and the file is resource.resx the xml would contain
application.plugin.resource.

We then create the ResourceManager:

resName = "application.plugin1.resource";
ResourceManager rm = new ResourceManager(resName, _pluginAssembly);

And ask for a string

CultureInfo ci = new CultureInfo("fr");
String str = rm.GetString("string", ci);

this returns the string that is in plugin assembly (plugin1.dll) rather
than the satellite assembly no mater which culture I ask for. Using
SysInternal's filemon I see the application looking for
\fr\plugin1.resource.dll then \fr\plugin1.resource.exe. Obviously the
same occurs for dialogs, I assume
System.ComponentModel.ComponentResourceManager (used by default be the
IDE when you make a localizable dialog) is using the same rules as
ResourceManager.

Is there any way of getting resource from a subdirectory of \plugins\
rather then off of the base directory for those plugin resources?

Thanks

Nick

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assemblies and satellite assemblies Matze Microsoft C# .NET 0 18th Jun 2008 01:07 PM
loading the right resources with Satellite Assemblies Nader Microsoft Dot NET 1 15th Mar 2007 03:41 PM
Using resources in satellite assemblies with ASP.NET (semi-newbie) =?Utf-8?B?RFQ=?= Microsoft ASP .NET 1 4th Apr 2005 10:34 PM
Dynamically creating satellite assemblies with embedded resources =?Utf-8?B?Tm90cmUgUG91YmVsbGU=?= Microsoft Dot NET Framework 2 10th Sep 2004 11:28 AM
Resource manager load resources from multiple satellite assemblies? Notre Poubelle Microsoft Dot NET Framework 0 21st Jul 2004 10:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:44 AM.