简体   繁体   中英

dll plugin architecture with castle windsor

I have an IPlugin interface and a IPluginFactory What I want to do is to be able to add new implementations of IPlugin at runtime (for instance, adding a Dll with a new implementation to a "Plugins" folder).

I'm using Castle Windsor as my IoC container and I'm using TypedFactory facility to implement the IPluginFactory. So here is my question:

How can I register new IPlugin implementations at runtime in windsor (I'm thinking in something like adding a Dll that contains a WindsorInstaller but I'm not sure how to proceed)

Windsor has some support for plugins but it's not the primary goal of the framework. Most notably, Windsor does not provide any out of the box mechanism for discovering that a new .dll has been dropped into a directory. It also does not provide any form of OOTB isolation from plugins (in form of hosting them in separate AppDomain or other). Neither does it provide ability to unload plugins/components (there's a container.RemoveComponent() method, but it's not really working and is removed in upcoming Windsor 3).

Perhaps a combimation of MAF and MEF would better suit your requirements if you need to do those things at runtime.

If you relax your security requirements (no isolation) and your runtime change requirements (to be once, at start-up time ) Windsor can support this scenario.

The best way to do it is to have some installers ( IWindsorInstaller ) in your plugin assembly and use

container.Install(FromAssembly.InDirectory(...));

methods to discover those assemblies and run installers registering your plugin components.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM