Rakesh Rajan's blog

Thoughts on .NET, software and a few trivial things...

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:

  1. you want other people to create plug-ins for your application without exposing your source code
  2. you have a module which keeps changing but don't want to recompile your application every time it changes

Solution overview

  1. 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.
  2. Create a plug-in by implementing the interface, and build it as an assembly
  3. Let the application know about the plug-in assembly, by using either the app.config file or any similar mechanism.
  4. 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

Posted: Apr 14 2005, 11:23 AM by rakeshrajan | with 2 comment(s)
Filed under:

Comments

TrackBack said:

How to create a Plug-in architectureooeess
# May 24, 2005 2:50 AM

TrackBack said:

How to create a Plug-in architectureooeess
# July 22, 2005 3:29 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)