Sunday, 13 May 2012

SQL Management Studio (SSMS) 2008 R2 Add-Ins v2.0

Following up on my previous post, I have created a new framework for SQL Management Studio SSMS based on MEF (Managed Extensibility Framework).


I created my first SQL AddIn as an IronPython Add-in with the idea to explore the IDE environment more easily allowing for interactive add-in development and to add developer features on the fly. It worked really well but I found that under certain circumstances you wanted to write an Add-In that were static and type safe as well as being as performing as native C#. So I created a new framework using MEF (Managed Extensibility Framework). This allows you to override a very simple base class and just “fill in the blanks” to have your very own Add-In. This also allows me to also create run the IronPython Add-In on top of this to allow for fast testing and prototyping and until you figure out what you wanted to do and how it works and then proceed to use native C# and then just drop in your assembly.

On top of the framework I have created 3 Add-Ins (Plug-ins)

The famous IronPython Add-In:


The Procedure List:


Scans the active document and displays a GExperts style listing of the objects.


Sample command:

A very simple add-in showing you how it all works.



For the installation packages please visit this link:

For the source code please access this page:

This is a mercurial enabled repository so please follow the links provided to download the source code.

Using the SourceCode.

Load the solution


Build the solution

You may get errors like this:


This is fine and only because you have not installed the main add-in and haven’t created the plugins yet. This is just a post-build event to copy the python scripts into the install directory.

Also if you are not planning to use or install the IronPython plugin, you may unload the project to prevent this from happening.

Also this assumes that you will install the project under c:\program files (x86). If this is not the case you may modify this by opening the project properties, post build event.


Now that you know whats going on it is time to install the main MEF Addin.

Locate the project MEFAddinSetup

Build and install it:


Just run through the default install:



Once installed the program files directory should look something like this:


Starting up SQL Management Studio 2008 will now look like this:


Congratulations you now have the MEF AddIn installed successfully.

Now it is time to add some plug-ins.


The plugin system of the new MEF extensible addin is a case of simply dropping compatible assemblies in the installation folder.

You will notice that each plugin has a System.ComponentModel.Composition:


The plugin must also have an export attribute for a command:


And for each controller:


Commands vs Controllers.

By looking at the sample controllers and commands you will see that the implementation of the controller is simply to override a controller and command class.

The controller is slightly more complicated and allows you to respond to all the events from the IDE. Where the command is intended to give you a simple method for adding a command to the command bar and just responding to its execution event. The Python add-in has an example of a Controller implementation and the Procedure List and Sample command has one for a command.

You will notice the plug-ins in the Plugins folder in the solution


The first plugin is just a sample to show you how a plugin is created. It adds a command to the command bar and just prints a message once executed.

The ProcedureList is another plugin I created previously that I ported to the new framework to display a list of objects in the document once activated, much like GExperts.

Then finally my first flagship plugin the IronPython that has also been ported to the new framework.


Simply build the plugins in the plugins folder NOTE: The Python plugin may fail due to reasons above, if so copy the relevant, scripts, Icons files to the installation folder and rebuild

Finally copy the outputs of each plugin to the installation folder:

My installation folder now looks like this:


Starting SQL Management Studio now you can see the additional plugins installed.


That’s it for now, look out for awesome future add-ins I have planned.

No comments:

Post a Comment