I'm Keyvan Nayyeri, a 25 years old Ph.D. student at
the Computer Science department of
the University of Texas at San Antonio.
I'm also
a Software Architect and Developer and previously held a B.Sc.
degree in Applied Mathematics.
This is my blog where I publish content about various topics specifically Programming Languages and Compilers, Software
Engineering and Programming.
Two days ago I started a new post series to discuss Visual Studio add-in and integration package in order to introduce their structure, applications, differences, commonalities, and how to upgrade from an add-in to a VSPackage. My main goal is to cover some aspects of this discussion that have been an ambiguous part of Visual Studio Extensibility for a newbie.
In the first post of this series, I gave a quick overview of the past history of Visual Studio Extensibility, these two options, and how they evolved during the past decade or so. In this second part I want to review the technical structure of an add-in along with its applications.
In fact, the term add-in refers to something general in Microsoft products including Visual Studio IDE and Office Suite and in Visual Studio it’s known as VSAdd-in. But it’s common among Visual Studio users and developers to simply call it “Add-in”.
But what’s the application of an add-in and why it’s designed as a part of Visual Studio extensibility?
Add-in is actually an extension to Visual Studio that lets developers apply high level APIs of the Visual Studio and Development Tools Extensibility (DTE) to extend Visual Studio in several ways but with some limitations that relate to the API that they can use.
Above paragraph states some important facts about add-ins:
Now that you read a quick definition of add-in and a short description about important aspects of an add-in, let’s dig into more details about add-ins.
From a technical point of view add-in is a compiled package of code that can run by a mechanism in Visual Studio known as Visual Studio add-in system. This is in opposite direction to the definition of VSMacro that is not a compiled piece of code.
Add-in is a COM component. It means that add-in, like many other COM components, implements a programming interface for a component. In general Visual Studio Extensibility consists of lots of these interfaces and their corresponding implementations to enable interoperability between .NET and COM.
The development mechanism of add-ins is a built-in part of Visual Studio and there is a Visual Studio template for this purpose.
From a technical point of view add-in implements IDTExtensibility2 interface from EnvDTE80 namespace (this is of course what you see in Visual Studio 2005 and 2008 and names are different for prior versions). This interface contains five methods that can be implemented to handle events that let you implement your logic for these main events including OnConnection, OnDisconnection, OnAddInsUpdate, OnStartupComplete and OnBeginShutdown. The structure of an add-in is shown below.

Beside this, there is an XML file with a .vsaddin extension that acts like a configuration file for your add-in and you must configure it.
Before Visual Studio 2005, the deployment of add-ins was a little hard and required the registration of COM assemblies on the machine but thank to the introduction of this .vsaddin file, now you just deploy the assembly and this configuration file to a specific path.
You’re able to integrate an add-in into Visual Studio as a part of some user interface elements. You can add a Visual Studio command for your add-in to the IDE and then use this command to achieve many things.
For example, you can add your add-in to the user interface as a new menu item for default Visual Studio menus or right-click menu.
Since add-ins have access to the automation model API, they can do many things that I outline some of them here:
These are some main tasks that add-ins can do but besides them, you’re able to design your own user interface for the add-in to show to the user in order to return outputs or get inputs. Moreover, you’re able to integrate a Tools Options Page in order to have dynamic configuration and settings for your add-ins.
There is a Visual Studio mechanism to load and run add-ins. This mechanism looks for add-in files in specific paths (that you can modify) and then loads all valid add-ins (that implement the interface and have a valid .vsaddin file). After loading these add-ins, it calls the specific method whenever that event type occurs. You saw that there are five main events that an add-in implements and can respond to them when Visual Studio calls such methods.
By implementing an extra interface called IDTCommandTarget and registering a command for your add-in, you’re also able to respond to the command whenever it’s called and this lets you do much more things than what you can do by default implementation of add-in. This also lets others to develop macros and add-ins that will apply your add-in.

In general, there are many goals that can be achieved with add-ins quickly and easily. The development and deployment process of add-ins has been made much easier in Visual Studio 2005 and 2008, and now it’s the fastest way to extend Visual Studio with high level APIs.
Visual Studio Add-In vs. Integration Package – Part 2 - Keyvan Nayyeri
Aug 24, 2009 10:28 AM
#
Thank you for submitting this cool story - Trackback from DotNetShoutout
Arjan’s World » LINKBLOG for Aug 25, 2009
Aug 25, 2009 4:09 PM
#
Pingback from Arjan’s World » LINKBLOG for Aug 25, 2009
Visual Studio Add-In vs. Integration Package – Part 3
Aug 27, 2009 9:51 AM
#
In the first two parts of my new post series about Visual Studio add-in and integration package as two primary options to extend Visual Studio IDE I gave a quick overview of the past history of Visual Studio Extensibility with an emphasis on these two
Visual Studio Add-In vs. Integration Package – Part 4
Sep 06, 2009 1:03 PM
#
In the first three parts of my post series about two major extensibility options in Visual Studio, add-in and integration package, I gave an introduction , discussed the technical structure of an add-in with its applications , and talked about the integrated
Visual Studio Add-In vs. Integration Package - Part 5
Sep 13, 2009 12:43 PM
#
Recently I started a new blog post series on Visual Studio Extensibility and two major options available in this technology known as add-in and Visual Studio integration package. So far I’ve written four parts covering the following topics: An overview
Keyvan Nayyeri
Oct 09, 2009 11:51 AM
#
Leave a Comment