22 Comments

Some applications require that they’re constantly running. Whether they are mission critical systems, web servers or irc bots, users will be affected if the application is taken down even for a short period.  Imagine what you could if your application could be upgraded and changed without ever closing it down? It’s easy to list some benefits for an application like that:

  • Update wrongly behaving parts of your programs without shutting it down completely
  • Test your changes rapidly
  • Allow an easy deployment of application plugins

In this post we’re going to take a look on a simple Windows Forms application which can be extended through the use of plugins. The application demonstrates two features which are required for the always running systems:

  • Updating an existing feature on the fly
  • Installing a new feature on the fly

You can find the link to the source code and executables from the bottom of this post.

Infrastructure

The sample application is written with the following tools:

  • Visual Studio 2010
  • .NET Framework 4.0
  • Structuremap IoC-container

Sample application

Did I mention that our sample application is simple? Well, here it is in our full glory.

app

Our application is a simple Windows Forms client. The application’s plugins are stored in binplugins –folder and they are .NET-assemblies. One assembly (dll-file) can contain multiple plugins for our application. To keep things simple, every plugin implements an IPlugin-interface.

When you run the application and click the “Run my features”, it will execute all the functionalities provided by the plugins. When you click the “Update my features” and then the “Run” button, you’ll see how an existing feature has been updated on the fly. If you then click “Add new features” and then again “Run”, you’ll see how more functions has been added to the application.

Behind the scenes the “Update my features” will replace the binpluginsplugin.dll-file with a plugin.dll from a binpluginsarchive-folder. “Add new features” will copy the plugin2.dll from the archive folder into the plugins-directory.

Full-blown example?

For a more complicated application you can see the source code of the following irc bot, which allows the developer to add new commands (AuthenticateMe etc.) and irc event handlers (triggered by events like UserChangedTopic) without dropping the bot from the server. Existing commands and event handlers can be also modified on the fly.

Future posts

This is not all. In the following days we’re going to jump to the details of the implementation behind this simple application. At least the following topics will be covered:

Download

You can browse and download the sample application’s source from GitHub.