JG Vimalan's Blog

It is all about coding!

Create a Addin for Visual Studio

This post describes the steps involved in creating an addin for Visual Studio. To create a Addin project, click File->New->Project choose ‘Extensibility’ under ‘Other Project Types’. Follow the instructions in the wizard to create the Addin project. Once you create the project, Connect.cs file in the project. The .cs file contains the OnConnection method. In this method, you can set the menu item under which your addin should appear as well as your addin name.

  public void OnConnection(object application, …
   _applicationObject = (DTE2)application;
   _addInInstance = (AddIn)addInInst;
   if(connectMode == ext_ConnectMode.ext_cm_UISetup)
    object []contextGUIDS = new object[] { };
    Commands2 commands = (Commands2)_applicationObject.Commands;
    string toolsMenuName = “View”;

Now, if you run the application, you will find the addin under the ‘View’ menu item in visual studio,

To add fuctionality to this addin, use the Exec method in the Connect.cs file. Here, I have added a piece of code to display a message. 

public void Exec
            (string commandName,
            vsCommandExecOption executeOption,
            ref object varIn,
            ref object varOut,
            ref bool handled)
   handled = false;
   if(executeOption ==
    if(commandName == “MyVSAddin.Connect.MyVSAddin”)
     handled = true;

                        “Hello Universe!”,
                        “Custom Message”,

you can your own logic, launch a form, etc.,

So, on clicking the Addin, the Exec method will get fired and the message box will be displayed as shown below,

October 28, 2010 - Posted by | VS 2010

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: