Skip to Main Content
Professional Visual Studio® 2008
book

Professional Visual Studio® 2008

by Nick Randolph, David Gardner
July 2008
Intermediate to advanced content levelIntermediate to advanced
1026 pages
27h 59m
English
Wrox
Content preview from Professional Visual Studio® 2008

52.3. The Anatomy of an Add-In

The Add-in Wizard generates a solution with a single project in it. This project contains a Connect.cs file, which is the main implementation file for the add-in, as well as two files with the .AddIn extension and a resource file for command bar resources.

The main parts of the add-in are the Connect.cs file and an .AddIn file. In earlier versions of Visual Studio you had to register the COM component by hand for an add-in on the machine, so deployment was harder than what you see in Visual Studio 2005 and 2008, but with the introduction of .AddIn files this process has been made simpler. .AddIn files are XML files that act as configuration files for add-ins. You'll read more about them in the next section, but for now let's focus on the add-in anatomy and the Connect.cs file.

First, look at the generated code for the Connect class:

using System; using Extensibility; using EnvDTE; using EnvDTE80; using Microsoft.VisualStudio.CommandBars; using System.Resources; using System.Reflection; using System.Globalization; namespace Chapter52 { public class Connect : IDTExtensibility2, IDTCommandTarget { public Connect() { } public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; if (connectMode == ext_ConnectMode.ext_cm_UISetup) { object[] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)_applicationObject.Commands; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Visual Studio® 2010

Professional Visual Studio® 2010

Nick Randolph, David Gardner, Michael Minutillo, Chris Anderson

Publisher Resources

ISBN: 9780470229880Purchase book