tags:

views:

95

answers:

4

Hey, I'm working on a project in C#, it's about E-learning.This project should use plug-ins as its main inputs, it can't function without them. I have no idea how can I work with plug-ins, I know nothing about how can a plug-in compile inside my program, or how can I install them inside my application. I'm asking here about references, or any useful ideas that can help me with this.

+2  A: 

Use MEF, looks great.

http://www.codeplex.com/MEF

Pablo Castilla
+3  A: 

Start by creating a Plug-In Interface:

public interface IPlugIn
{
    // Your stuff here
}

You can then distribute your interface to the developers working on the plugins.

When your application starts up, it can load all Plug-In assemblies dynamically, then work with them through the IPlugIn interface without needing to know the internals of each one.

UPDATE

I actually found an article that goes into the process I described in more depth with more ellaborate examples. You can check it out here:

Writing Plugin-Based Applications in .NET

And an added bonus...it comes with Code Samples!

Justin Niessner
Thanks so much I think I'll go with this simple method, if you have more experience or references about this please let me know, thanks again :)
Shaza
A: 

There is also Mono.Addins: http://www.mono-project.com/Mono.Addins

Emmanuel
+1  A: 

if your plugin is not too complex you can avoid using extensibility frameworks like MEF.

  1. You define contract for plugin. It should be public interface, or may be class with abstract/virtual methods. You should move it to separate assembly and distribute to plugin developers
  2. Developers implement interface and produce assemblies
  3. Use Assembly.Load to load in runtime.
  4. List types by GetTypes
  5. Find types that implement your interface
  6. Activator.CreateInstance
  7. Have fun
Andrey