tags:

views:

61

answers:

3

In my .NET application I allow people to add their plugins. However I've got several helper functions which will help them.

What's the best way to provide access to these functions for plugins?

Shall I just add a new DLL to the project and put all helper methods / classes to there and tell plugin developers to link that DLL?

I'm currently designing this system, never developed a plugin system before, so don't want to make a stupid decision.

+2  A: 

I don't think that there's anything wrong with the approach of adding a DLL to the project and providing that as your "helper" mechanism. However, keep in mind that you won't really have any control over how they instantiate classes in your DLL, and all the inputs to all the functions will have to be checked to ensure that they are valid, not null, etc.

Another idea would be to provide an interface which has the helper functions (or even references of other helper interfaces) and pass that in to the plugin. That way you don't have to worry about object creation, and the vector of how they would use the add-ins would be limited to what you expose in the interface.

scwagner
For those who don't have time to invest in another framework, I totally agree.
EnocNRoll
+1  A: 

The Managed Extensibility Framework (MEF) was created with idea of adding plugins to your code

MEF Programming Guide

Chris Marisic
Do you know how to this in MEF? I've implemented MEF with an interface and it works great but what about helper functions? I couldn't see any page about that.
dr. evil
+1  A: 

Ultimately you will exposing your API through assemblies, so yes, it's probably easiest to put all the classes, static methods, etc. that are meant to be part of the API into a single assembly so that your plug-in writers will have a single point of reference.

AdamRalph