Referencing Automation Assemblies and the DTE2 Object

To create automation applications, you must perform steps to gain access to the automation members. First, you must reference the requisite automation assemblies, and second, you must get a reference to the top-level object, DTE2.

In Visual Studio .NET 2002 and Visual Studio .NET 2003, all core automation items were located in an assembly named EnvDTE, and its highest, hierarchical object is the DTE object. It is the parent object for all core automation objects, collections, and their members. DTE2 derives from DTE.

In Visual Studio 2005 and Visual Studio 2008, additions and updates were made to some of these objects, collections, and members. Rather than update the existing assembly and compromise backwards-compatibility for existing add-ins and automation projects, all new, updated functionality is in an assembly named EnvDTE80 (EnvDTE version 8.0) and EnvDTE90 (EnvDTE version 9.0). Most updated functions in EnvDTE80 and EnvDTE90 maintain the same names as previous versions but append a number to the end of the function name. For example, the newer version of the TaskItems collection is named TaskItems2, and the newer version of the Solution object is named Solution2. Because the new members are more robust than previous versions and contain the latest functionality, the recommended approach is to use the new objects and collections when writing new automation applications. 

Although new items are in EnvDTE80 and EnvDTE90, most of the core automation functionality is still in EnvDTE. So, when you write new automation applications (such as add-ins), be sure to reference EnvDTE, EnvDTE80, and EnvDTE90. You can do this in one step by referencing the COM libraries "Microsoft Development Environment 8.0" and "Microsoft Development Environment 9.0." Also, if you use members from the EnvDTE assembly, you must also set a reference to both the DTE object and the DTE2 object. This gives you access to all of the items.

For information about gaining access to the project-specific object models, see Functional Automation Groups.

In This Section