Deconstructing Add-In Architecture in Visual Studio .NET : Page 3
The Visual Studio .NET extensibility model included with the IDE allows any developer to design and compile value-adding custom add-ins right out-of-the-box. No additional APIs or tools are required. Visual Studio .NET even provides a starting point for add-in developers with the Visual Studio .NET Add-In Project type.
by Michael Lane Thomas
Nov 26, 2003
Page 3 of 7
Basic Add-In Architecture
Visual Studio .NET requires an add-in compiled as a .NET assembly to be registered as a COM object.
The team responsible for designing the extensibility API in Visual Studio .NET stipulated few requirements for a .NET class to have the ability to function as an add-in. The Visual Studio .NET Add-In Project type provides a wizard to generate a great deal of basic coding elements that have the tendency to hide the bare essence of what is actually required. Later I'll show you the results of using this Project type as a starting point for your add-in, but for now, let's stick just to the bare facts.
The immediate requirement is that you should with a Class Library project. You should add a single class to this project. You will need to reference three primary assemblies that provide interfaces and UI elements used by most add-ins. With the Add Reference wizard, you should add references for:
These assemblies will provide the core interfaces you will need to implement and the access to the primary interop assembly for the Office menu controls, allowing use by your add-in of the core set of UI controls used by Visual Studio .NET for the command bars, context menus, and menu items.
Most add-in projects will greatly benefit from the use of a core set of imports statements at the top of the code file.
Meeting the Three Primary Requirements
The public assembly extensibility.dll, shown in Figure 4, contains a single element, the IDTExtensibility2interface. In order to write a class to function as an add-in, you should first start by implementing IDTExtensibility2and its five methods: OnConnection, OnDisconnection, OnAddInsUpdate, OnStartupComplete, and OnBeginShutdown. As far as coding goes, this is the only requirement. Two more requirements exist in order to allow Visual Studio .NET to be aware of and load your type as an add-in.