By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,458 Members | 1,003 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,458 IT Pros & Developers. It's quick & easy.

Loading resources from satellite assemblies of reflection loaded assemblies..

P: n/a
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

Nov 23 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.