开发者

c# plugin system question

开发者 https://www.devze.com 2023-01-22 02:19 出处:网络
so I implemented a really simple plugin system. i have the following Assemblies: MainApp IPlugin PluginApp

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 the开发者_运维问答ir own copy of IPlugin.dll so they are not recognized as a match when using Type.IsAssignableFrom()!

help?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消