Composing an Application by Combining Extensions


DotSpatial is an open-source project that contains controls which can be used to manipulate and display geographic information. MapWindow 6 is a thin wrapper around DotSpatial. This article explains how to create an application like MapWindow 6 or HydroDesktop, by combining extensions to get the desired set of functionality. Some extensions are included by default with DotSpatial builds while others can be found in the Extension Manager.

Obtaining Extensions

Presently, we don’t make any distinction between the terms add-on, plugin, or extension. In general, these refer to a class that provides some functionality designed to complement DotSpatial and inherits from IExtension (or implements Extension).

There are other types of extensions that provide a more specific type of functionality such as DataProviders, HeaderControls, and ProgressHandlers. These inherit from specific interfaces such as IDataProvider, IHeaderControl, IProgressHandler and so on. They are less general purpose in nature.

Extensions can be obtain in a number of ways:

Codeplex Downloads – the Extended release package includes additional extensions.

DotSpatial Package Feed – updated extensions are built and pushed to the feed automatically. The feed may also include user-contributed (closed source) packages and is used by the Extension Manager.

The Extension Manager – the extension manager itself is an extension. It allows the user to download additional extensions.

You – you can create your own DotSpatial extensions as well. Then you can compose various applications by including the appropriate extensions that result in the desired set of features.

Installing Extensions

There are three different places an extension may be placed. Each yields slightly different functionality. A programmer may also add additional directories to the appManager.Directories property so that additional directories are searched. When installing an extension, you’ll need the extension assembly (dll) as well as any of its dependencies. The built in assembly resolver allows you to create an extension that depends on another.

Plugins folder – when a developer builds the DotSpatial project, extensions are placed in the Plugins folder inside of the application folder. These extensions (assuming they inherit from IExtension) may be activated or deactivated by the end-user. If you are deploying your application with a specific set of extensions that you wish to behave in this way, this is the right place for them.

Application Extensions folder – extensions placed here will be activated when the application launches; the user will not be able to deactivate them. This allows the developer to create a set of extensions that make up the branding of the application. From the user perspective, these are part of “the application”, and the developer can use this flexibility to divide up application logic into multiple extensions. An end user wouldn’t be able to tell whether the feature was built into DotSpatial, or was an extension.

Extensions folder – this folder is placed in the user profile folder inside of a folder based on the application assembly name. You can open this folder by clicking Show Extensions Folder in the Extension Manager.


The path would look something like %appdata%\DemoMap.exe\Extensions.

When users install or update packages from the online section of the Extension Manager, they are placed here.

Note: If an extension was originally in the Plugins folder, and the user chooses to update it, the new version will be placed in the Extensions folder and the existing version will be removed (after a restart).

Loading Extensions

When an extension is loaded, we guarantee that it will be able to access an AppManager, IProgressHandler, and IHeaderControl. This allows the developer to avoid checking whether these properties are null before each use. This means, however, that extensions fulfilling these requirements must be available. In DemoMap.exe implementations are included in the project itself as classes. In MapWindow 6, example implementations are included as extensions. You can use whichever suits you.

You may want to review a few related articles:

How to Support Loading Extensions (Loading GDAL)

How to Load DotSpatial Extensions Into My Toolbar

Case Study

The MapWindow 6 application is strictly a set of extensions, the DotSpatial library, a small amount of code to allow you to brand it with your own splash screen image and name, and a little code to deal with command line parameters.

The HydroDesktop application is a copy of MapWindow 6 with a different set of extensions and custom branding. Eventually, HydroDesktop can become more of an “extension pack” so that it can be downloaded into any DotSpatial compatible application.

Points of Interest

See Also: Using the Extension Manager

Extensions can communicate with one another using the Managed Extensibility Framework (MEF).

Setting AppManager.UseBaseDirectoryForExtensionsDirectory can alter the location where extensions are installed by the Extension Manager.


One thought on “Composing an Application by Combining Extensions

  1. Pingback: How to Customize Branding of MapWindow 6 « Mudnug

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s