Running the Add-in

 < Free Open Study > 

When you create an add-in using the Add-in Wizard and then run it, another instance of Visual Studio .NET starts, allowing you to test and debug the resultant add-in. Normally, one or more commands for the add-in are placed on one or more menus, such as the Tools menu. When you finish debugging the add-in and then close this second instance of Visual Studio .NET, the command information is saved. When you eventually close the first instance of Visual Studio .NET, however, the command information that was written by the second instance of Visual Studio .NET is overwritten. The effect is that when you restart Visual Studio .NET, your new add-in command no longer appears on the menu. To restore commands to menus, you can run an included registry (.reg) file that is generated by the Visual Studio .NET Add-in Wizard.

Having said this, you will recall that you put code in the OnDisconnection method of the Connect class to remove your add-in menu item. I believe that it should be the responsibility of the add-in developer to place and remove the add-in's menus or tool buttons as the add-in is loaded and unloaded. To leave an add-in's menus in the IDE, even though the add-in is not running, is confusing to the application developer using the add-in.

I discuss the debugging process in detail in Chapter 4. For now, you have two ways of running the add-in.

First, you could do a full build followed by an installation of the add-in. From that point, the next time you start the .NET IDE, the add-in will be loaded and connected. When the IDE is unloaded, the add-in will be disconnected.

Alternately, you can simply press F5 or click the Run button on the main toolbar. The add-in will go through the build process, and if the build is successful (has no errors), a second copy of .NET will be loaded automatically. As it loads, it will load and connect your add-in.


If your add-in does not connect when the second instance of Visual Studio .NET is started, go to the Add-in Manager dialog box and check both check boxes for the add-in.When you close the dialog box, the add-in should connect and display its user interface.

If you had placed breakpoints in the code of the Connect class, for example, in the OnConnection method, your code would be stopped at the breakpoints.

Regardless of the method of execution, the add-in will be loaded and connected. As the IDE loads, your add-in will be started. You will recall that you placed a MsgBox display in the OnConnection method of the Connect class. When Visual Studio starts the add-in, it will call the OnConnection method and you will see the MsgBox displayed with the "On Connection" message.

If you click the Tools menu, you will see the add-in's tool button at the top of the Tools menu, as shown in Figure 2-12. Your add-in's menu text is "Click Me" and it is highlighted.

click to expand
Figure 2-12: Add-in menu item

If you now click the selected menu item, the add-in will display a box with the message "You rang?"

 < Free Open Study > 

Writing Add-Ins for Visual Studio  .NET
Writing Add-Ins for Visual Studio .NET
ISBN: 1590590260
EAN: 2147483647
Year: 2002
Pages: 172
Authors: Les Smith © 2008-2017.
If you may any questions please contact us: