How to create a Plug-in architecture
Problem
You want to create an application which could dynamically load ‘plug-ins’ at
runtime. You want to do this because:
-
you want other people to create plug-ins for your application without exposing
your source code
-
you have a module which keeps changing but don't want to recompile your
application every time it changes
Solution overview
-
Create an interface which all plug-ins must implement, and have it shared as an
assembly referenced by both your application and the plug-ins.
-
Create a plug-in by implementing the interface, and build it as an assembly
-
Let the application know about the plug-in assembly, by using either the
app.config file or any similar mechanism.
-
At run time, use Reflection (Activator.CreateInstance method) to create an
object of the plug-in and store in a variable of the interface type.
Suggested references