Reputation: 8206
I read this aricle How to load plugins in .NET?, and I really don't see the brilliance of Microsoft's System.Addin namespace. Why can't I just have a plugins folder in my bin directory that users can put an assembly into that implements an interface I design? I could then just use reflection to create an instance of the plugin class and reference it with my interface.
Why is the System.Addin way apparently so much better? Especially since it seems like three times the work and a less intuitive design.
Upvotes: 10
Views: 7837
Reputation: 15722
"so much better" always depends on your point of view and requirements. If your approach fits your needs, go for it. But plugins can become very fast much more complicated. What about dependencies between plugins? Security? Different schemata how to find plugins? ...? Those kind of features are already solved for you. If you don't need them, a library might be overkill. If you need them, it would be a bad idea to reinvent the wheel. ;-)
Upvotes: 6
Reputation: 29664
Look at Microsoft's Managed Extensibilty Framework; the code is open sourced so you could use it a basis to write your own, or you could just use MEF directly.
Upvotes: 2
Reputation: 564771
I would recommend looking at the Managed Extensibility Framework (which was added to the core framework in .NET 4). It allows you to do exactly what you're describing, and is very simple and flexible to use in extensibility scenarios.
Upvotes: 10