JDB site

VS Add-ins

VS Add-ins

Hello World

To create a new Add-in project, we will use the Add-in Wizard built into Visual Studio.

There are two types of Add-ins you can create, one that can be loaded into Visual Studio (which is the focus of this article), as well as a shared Add-in that can be used across different Microsoft products (such as Word, Excel, Outlook, etc.)

Next page
VS Add-ins

Select your language

After the wizard splash screen, you will be given the option to select the programming language you want the code to be generated in. The options are:

You many use whichever language you are most comfortable programming in. This choice determines the language the Add-in project will be generated in, but does not impact running or using the Add-in.

Prior Next page
VS Add-ins

Application Hosts

The application hosts selection screen lets you indicate which hosts application can run your Add-In. The options are:

You can check either or both options. For now, you only need to check Visual Studio. The Add-in XML file will contain an entry for each option checked.

Prior Next page
VS Add-ins

Name and Description

Prior Next page
VS Add-ins

Add-on Options

Prior Next page
VS Add-ins

About

Prior Next page
VS Add-ins

Summary Screen

Prior Next page
VS Add-ins

Saying "Hello"

The generated code includes an Exec() method which is where youíll add the code you want your Add-in to execute. The Handled variable, passed by reference, should be set to true to inform Visual Studio that the particular command was processed by the Add-in method.

   public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
   {
	  handled = false;
   	if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
	  {
		 if(commandName == "HelloWorld.Connect.HelloWorld")
       {   MessageBox.Show("Hello World!", "Hello" ,MessageBoxButtons.OK);
      		handled = true;
		       return;
		 }
	   }
    }
    

Prior

Code Models

Visual Studio and Code models stuff here...

VS Add-ins
VS Add-ins

Deploying an Add-in

Once the Add-in mode you have developed is ready to go, you probably will want to share it with your fellow developers. Fortunately, it is very easy to install your Add-in.

Installing the Add-in

To install your Add-in, you will only need to copy two files to the one of the folders where Visual Studio looks for Add-ins modules. This is usually \Documents\Visual Studio 2010\Addins\. You can also look in Visual Studio's Options dialog, under the Environment node, Add-in/Macro security page for the Add-in File path list..

If you copy the Assembly DLL file and the .AddIn XML files to this folder, Visual Studio will discover it and possibly load it next time Visual Studio is started.

Add-ins

Class Documenter

Download

This Add-in finds all of the public elements from a class and documents them as a comment text, so this becomes THIS

Add-ins

Class Documenter

Download

Back to BEFORE example

Works with Visual Basic and C# source code, and will update comment text if run more than once.