Chapter 32
Once it has been located, it drills down into the menu bar object to find the object into which the add-in command will be inserted, which in this case is a CommandBarPopup object. Once it has this information and the named command has been created, you can use the command’s AddControl method to connect the command and menu.
You can use a similar method to place your command anywhere within the IDE’s collection of menus and toolbars. Simply replace the string “Tools” with the English string representing the menu you want to hook into.
CreateToolWindow2
You can even create your own tool windows that are used as part of your add-in. The CreateTool Window2 method forms the basis for creating a new tool window in the IDE, and requires that you first create a (standard) user control to be hosted inside its container space. This capability to host a user control means you can build complex user interfaces that reside within the IDE’s workspace, and they can be docked, resized, and moved just like all the other tool windows that come with Visual Studio.
Debugging
Because add-ins are created with managed code right within Visual Studio, you can use all the same debugging procedures available to you for any other Windows application. Remember that the Debug property page for the project will default to starting up an additional instance of Visual Studio 2005 and host the debugged version of the add-in in that, so if you need to test out the add-in in the Macros IDE, changing the startup settings on that page.
Refer to Section IX for more information on debugging Windows projects.
Registration and Deployment
Add-in registration is performed with the new .AddIn configuration file mentioned earlier in this chapter. Within this XML-based file you specify the various settings that control how your add-in should be loaded and which hosting applications can use it. To deploy it, simply place this .AddIn file in the Addins folder so Visual Studio 2005 can find it. You can specify that the add-in should be available to all users or a specific user by placing it in the appropriate folder. For all users, the location is \Documents and Settings\All Users\My Documents\Visual Studio 2005\Addins. Replace the All Users string with the specific user name if you want to restrict it to a particular user.
When Visual Studio 2005 starts, it will look in this folder for any add-ins that should be loaded. When it locates an .AddIn file, it reads through the XML to locate the Assembly tag, which dictates where the actual add-in DLL is to be found.
You no longer need to register your add-in through COM as you did with previous versions of Visual Studio .NET!