views:

55

answers:

1

so I implemented a really simple plugin system.

i have the following Assemblies:

MainApp
IPlugin
PluginApp

Both MainApp and PluginApp conatin a reference to the IPlugin. Now, in MainApp I scan a plugins folder and search for things that implement the IPlugin interface.

However, it is not working because both MainApp and PluginApp reference their own copy of IPlugin.dll so they are not recognized as a match when using Type.IsAssignableFrom()!

help?

+1  A: 

You could try putting your code that defines the plugin into a satellite dll assembly. That way both your main code and the plugins reference the same types.


If the plugin can maintain it's own dll instead of using the same dll as the application you will run into versioning issues. How will your main app handle calling plugins that don't implement the same interface?

When we did this in our own software we had to resort to reflection method calls instead of casting to the interface. It wasn't elegant.


What about adding the assemblies dll into the plugin directory. They have to reference the dll when they create their application, but force them to use the main assemblies version of the dll when the plugin is actually run?

wllmsaccnt
Errr...I used the wrong term. Satellite assembly is actually used to house resources. I meant an assembly that can host the interface code but that would not be hard coded into the main assembly.
wllmsaccnt
I am actually already doing that (IPlugin.dll). How can I ensure that plugin creators will use my dll? And if someone happened to include their own dll into their project, how can I prevent my app from falling apart?
whydna
When you compile the main app you set the specific version property to true on the reference to your iplugin dll. Your app won't start without the correct version. The plugin dll projects should not have the specific version property set to true.
wllmsaccnt