Generic plug-in application in C#

10 Mar

At work, we are about to build a new internal tool for administration of different systems. We developers need certain applications and the sales department needs some other ones. All the different people need to be able to administrate different systems, so we decided to create one application that hosts only the applications the individual needs.

Last weekend I played with a generic application that hosts other applications by using reflection. The Plug-in Application does nothing but manages the different plug-ins and let you add and remove plug-ins as you please. When a plug-in is added, it is added to the menu so that every time you open the application, you have easy access to the plug-in.

Each plug-in is in essence a .NET Windows Forms application, but you can also compile the WinForm into a .dll file so it cannot be opened outside the application.

This is what it looks like when the plug-in “TestForm” is running in the application.

Now the plug-in is maximized.

By clicking on the menu item “Manage Plug-ins” it pops up a manager that lets you add and remove plug-ins.

How it works

To make your Windows Forms application compatible with the application, you need to let the main form inherit from a class called PluginForm. The PluginForm resides in its own assembly and is also referenced by the Plug-in Application. It only contains a property called Description and that is used to display tooltips on the menu and in the Plug-in Manager. Your main form needs to inherit from the PluginForm in order to know which form is the one to use in the Plug-in Application.

When you add a plug-in then the Plug-in Application creates an XML document that describes its location, icon, description and name. Because it does not copy the .exe or .dll file but only points to it, means that app.config and other files still work with the plug-in.

This is a simplified version of the one we need at Traceworks where we also needs security and other features. The Plug-in Application is so simple that it is easy to add such features.


The solution contains three projects. The application, the PluginForm base class project and a test plug-in. (243,15 KB)


Referenced by:


Posted by on March 10, 2011 in C#, Window Application


3 responses to “Generic plug-in application in C#

  1. james

    March 28, 2011 at 7:13 PM

  2. шпунтовые работы

    April 4, 2011 at 7:50 AM

    There is obviously a lot to know about this. I think you made some good points in Features also. Keep working ,great job!

  3. Buy Tramadol

    April 6, 2011 at 1:49 PM

    Great post. Just a heads up – I am running Ubuntu with the beta of Firefox and the navigation of your blog is kind of broken for me.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: