-
From the File menu, point to New, and than click Project.
The New Project Dialog Box appears.
-
In the Project Types pane, expand Other Project Types, and then select Extensibility.
-
In the Templates pane, select Visual Studio Add-in.
-
In the Name field, type SimpleAddIn as the name for your add-in project. Click OK.
The Welcome to the Add-In Wizard, Visual Studio Add-In Wizard starts.
-
In the Welcome to the Add-in Wizard page, click Next.
-
In the Select a Programming Language page, click Create an Add-in using Visual C#, and then click Next.
-
In the Select An Application Host page, accept the default options, and click Next.
-
In the Enter a Name and Description page, type Simple Add-in as the name for your add-in, and type Used to illustrate how to debug a simple Add-in. as a description for your add-in. Click Next.
-
On the Choose Add-in Options page, check the option, Yes, create a 'Tools' menu item. Accept the remaining defaults. Click Next.
-
In the Choosing 'Help About' Information page, select the Yes, I would like my Add-in to offer 'About' box information. option, and then click Next.
-
On the Summary page, click Finish.
The Add-in Wizard generates your new add-in project and opens the IDE with focus on the Connect.cs file. This is the main class that contains the code for your add-in.
-
In Solution Explorer, right-click the References node, and select Add Reference to add a reference to your assembly.
This permits the use of types in the System.Windows.Forms namespace.
The Add Reference Dialog Box appears.
-
In the .NET tab, double-click the component, System.Windows.Forms.dll.
In Solution Explorer, a reference to the System.Windows.Forms namespace is displayed under the References node.
This namespace contains the code necessary to display a Message Box, which is used in the following code example.
-
In Connect.cs, add the following statement near the top of the SimpleAddIn scope to permit easier use of a MessageBox object:
using System.Windows.Forms;
-
Add a MessageBox object to your add-in by adding MessageBox.Show("Debugging a Simple Add-in"); to the Exec method in Connect.cs:
public void Exec(string commandName,
vsCommandExecOption executeOption,
ref object varIn, ref object varOut, ref bool handled)
{
handled = false;
if(executeOption ==
vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if(commandName == "MyAddin1.Connect.MyAddin1")
{
handled = true;
MessageBox.Show("Debugging a Simple Add-in");
return;
}
}
}
-
Click the Save All button to save your work.