A
Arnaud Debaene
Hello group.
I have an app which can load "plugins" assemblies that are described
in the registry (each registry entry gives the full path to the plugin
..dll file). The plugins may be anywhere on the disk.
Each plugin defines a class which implements an interface known to the
app. The main app loads the plugin with Assembly.LoadFrom and then
uses Assembly.GetTypes() and Type.FindInterface to find the concrete
types in the plugin that implements the interface. An object of this
concrete type is then constructed by reflection (ConstructorInfo ->
Invoke).
All of this is rather easy stuff. Now a plugin and the main app
depends both on an utility assembly (let's call it Utils.dll).
Utils.dll and MainApp.exe are strong-named, Plugin.dll is not.
My problem is that the main app and the plugin are compiled at
different times and therefore reference different versions of
Utils.dll :
MainApp.exe --> Utils.dll V 1.0.0.0
Plugin.dll --> Utils.dll V 1.0.1.0
Plugin.dll is in a directory unrelated to MainApp. Therefore, I must
put Utils.dll V 1.0.1.0 in the GAC because Plugin.dll's path is not
looked for when loading the plugin.
Now, I can put Utils.dll v 1.0.0.0 either in MainApp directory, either
in GAC. But in both cases, I got a FileNotFoundException : "File or
assembly name Utils, or one of its dependencies, was not found" when
calling Assembly.LoadFrom("MyPlugin\Plugin.dll").
It seems that, although Utils.dll is strong-named, since Utils.dll V
1.0.0.0 is already loaded in the AppDomain, the GAC is not looked for
the correct version of Utils (1.0.1.0) and therefore loading fails.
Has anyone seen such a behaviour, and what would be the workaround?
I've got no trace in fuslogvw (why??).
Thanks,
Arnaud
MVP - VC
PS : Utils.dll has no dependencies itself (except on the framework).
There is no publishher file and no application configuration file
(since plugins may be distributed after the app)
I have an app which can load "plugins" assemblies that are described
in the registry (each registry entry gives the full path to the plugin
..dll file). The plugins may be anywhere on the disk.
Each plugin defines a class which implements an interface known to the
app. The main app loads the plugin with Assembly.LoadFrom and then
uses Assembly.GetTypes() and Type.FindInterface to find the concrete
types in the plugin that implements the interface. An object of this
concrete type is then constructed by reflection (ConstructorInfo ->
Invoke).
All of this is rather easy stuff. Now a plugin and the main app
depends both on an utility assembly (let's call it Utils.dll).
Utils.dll and MainApp.exe are strong-named, Plugin.dll is not.
My problem is that the main app and the plugin are compiled at
different times and therefore reference different versions of
Utils.dll :
MainApp.exe --> Utils.dll V 1.0.0.0
Plugin.dll --> Utils.dll V 1.0.1.0
Plugin.dll is in a directory unrelated to MainApp. Therefore, I must
put Utils.dll V 1.0.1.0 in the GAC because Plugin.dll's path is not
looked for when loading the plugin.
Now, I can put Utils.dll v 1.0.0.0 either in MainApp directory, either
in GAC. But in both cases, I got a FileNotFoundException : "File or
assembly name Utils, or one of its dependencies, was not found" when
calling Assembly.LoadFrom("MyPlugin\Plugin.dll").
It seems that, although Utils.dll is strong-named, since Utils.dll V
1.0.0.0 is already loaded in the AppDomain, the GAC is not looked for
the correct version of Utils (1.0.1.0) and therefore loading fails.
Has anyone seen such a behaviour, and what would be the workaround?
I've got no trace in fuslogvw (why??).
Thanks,
Arnaud
MVP - VC
PS : Utils.dll has no dependencies itself (except on the framework).
There is no publishher file and no application configuration file
(since plugins may be distributed after the app)