10

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.

Community
  • 1
  • 1
Jonathan Henson
  • 8,076
  • 3
  • 28
  • 52

4 Answers4

10

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.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
6

"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. ;-)

Achim
  • 15,415
  • 15
  • 80
  • 144
  • 1
    +1 for answering the crux of the question; MEF is a wonderful tool, but it's definitely not a full 'plug-in' framework, with AppDomain isolation, security, and versioning/dependency management. These additional features are usually over-kill for a simple application, but they are important considerations if you're building a large, mission-critical application. – Dan Bryant Jun 08 '11 at 20:12
2

You should use MEF, that question is from 2008

Antonio Bakula
  • 20,445
  • 6
  • 75
  • 102
2

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.

Esteban Araya
  • 29,284
  • 24
  • 107
  • 141