|
| Recent
Articles |

C# - Screen Scraping Some say that screen scraping is a lost art because it is no longer an advanced discipline. That may be right, but there are different ways of doing it. Here are some different ways that all are perfectly acceptable, but can be used for various different purposes. Old school. It's old...
C# Stock Quote Class A couple of months ago one of my readers asked me to build a stock quote class that would automatically update the quote. I forgot about it, but then I found the e-mail and decided to give it a go. I started looking for...
Overload Operators The Right Way In C# It's a good rule of thumb to overload the equality operators on classes. That ensures a correct comparison between to class instances of the same type. If you don't, .NET automatically uses reflection and that is...
C#: Realtime Currency Exchange Class Soon, I'm facing a new project where the need for up-to-date currency exchanges is crucial. This is not the first time I've done this, but I wanted to make a reusable, self-maintainable class so I don't have to do...
Validating Strong Passwords In C# And ASP.NET It's always a good idea to have a password policy when creating new applications. A password policy can vary from project to project, but the important part is just to...
Retrieve Subdomain From A URL In C# I had to come up with a method that retrieved the subdomain from the current web request on an ASP.NET website. I thought that the System.Uri class contained that information in an easy retrievable way, but no.
Working With Weeks In C# (Not That Obvious) For some reason, Microsoft didn't add a Week property to the DateTime class. I never could figure out why. Instead they gave us the System.Globalization namespace, filled with date related functionality like the different...
|
|
|
03.01.07 C# - Generic Plug-in Application By
Mads Kristensen 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.
Download
The solution contains three projects. The application, the PluginForm base class project and a test plug-in.
PluginApplication.zip (243,15 KB)
Comments
About the Author: Mads Kristensen currently works as a Senior Developer at Traceworks located
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and
web services in his daily work as well. A true .NET developer with great passion for the simple solution.
|
|