Share via


How to: Add References to Automation Namespaces

When you add a reference to EnvDTE, EnvDTE80, EnvDTE90, or EnvDTE100, you have the choice of using a .NET assembly or a COM library version. The one you should choose depends upon your project.

If you are maintaining an older application or add-in, you might need to use the COM version of EnvDTE, EnvDTE80, EnvDTE90, or EnvDTE100. If you are creating a new managed application or add-in, though, you will most likely want to use the .NET assembly version.

When you use the Add-in Wizard to create an add-in in any programming language or when you create a macro, the process adds references to the EnvDTE, EnvDTE90, Env90, and Env100 assemblies, and in the file containing the Connect class it adds using (in Visual Basic, imports) directives to the EnvDTE and EnvDTE80 namespaces.

To access the automation objects outside of macros or add-ins created with the Add-in Wizard, however, you must manually add the assembly references and using (in Visual Basic, imports) directives. When you add an assembly reference manually, you must also set the Embed Interop Types property of the assembly to false. To do this, follow the following steps:

  1. Add the assembly reference. In Solution Explorer, right-click on the project, then select Add Reference. On the .NET tab, select the assembly, then click OK. In a C# project, you will see the name of the assembly under the References node in Solution Explorer. In a Visual Basic project, you will see the name of the assembly in the project properties. Right-click the project in Solution Explorer, and select Properties. The properties pages will appear. Select the References page in the left pane.

  2. Select the assembly reference, and in the Properties window set the Embed Interop Types property of the assembly to false.

After you have references to the namespaces, you will most likely want to program against the DTE and DTE2 objects. For more information, see How to: Get References to the DTE and DTE2 Objects.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. These procedures were developed with the General Development Settings active. To change your settings, choose Import and ExportSettings on the Tools menu. For more information, see Visual Studio Settings.

To manually add references to the EnvDTE namespaces in Visual Basic or Visual C#

  1. In Solution Explorer, right-click either the project or the References node and click Add Reference, or click the Add Reference command on the Project menu.

  2. In the Add Reference dialog box, click the tab of the type of component you want, such as .NET or COM.

  3. Scroll down the list, select EnvDTE, EnvDTE80, EnvDTE90, and EnvDTE100.

  4. Click OK to add the two new references to the project.

  5. To enable Intellisense for the new assemblies in the code editor, at the top of your project's module or class, add one of the following:

    Imports EnvDTE
    Imports EnvDTE80
    Imports EnvDTE90
    Imports EnvDTE100
    
    using EnvDTE;
    using EnvDTE80;
    using EnvDTE90;
    using EnvDTE100;
    

To manually add references to the EnvDTE namespaces in Managed Visual C++

  1. In Solution Explorer, right-click the project node and click Add References, or click the Add References command on the Project menu.

  2. Click Add New Reference and then click the .NET tab.

  3. Scroll down the list, select EnvDTE, EnvDTE80, and EnvDTE90 and then click Add.

  4. Click OK to add the new references to the project.

  5. To enable Intellisense for the new assemblies in the code editor, at the top of your main project file, add the following:

    // Visual C++
    #using <envdte.dll>
    #using <envdte80.dll>
    #using <envdte90.dll>
    #using <envdte100.dll>
    

To add references to EnvDTE and EnvDTE80 namespaces to Non-Managed (ATL) Visual C++

  • In an appropriate header or source file, add the following:

    #pragma warning( disable : 4278 )
    #pragma warning( disable : 4146 )
    //The following #import imports EnvDTE based on its LIBID.
    #import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("8.0") 
    lcid("0") raw_interfaces_only named_guids
    //The following #import imports EnvDTE80 based on its LIBID.
    #import "libid:1A31287A-4D7D-413e-8E32-3B374931BD89" version("8.0") 
    lcid("0") raw_interfaces_only named_guids
    //The following #import imports EnvDTE90 based on its LIBID.
    #import "libid: 2ce2370e-d744-4936-a090-3fffe667b0e1" version("9.0") 
    lcid("0") raw_interfaces_only named_guids
    //The following #import imports EnvDTE100 based on its LIBID.
    #import "libid: 26ad1324-4b7c-44bc-84f8-b86aed45729f" version("10.0") 
    lcid("0") raw_interfaces_only named_guids
    #pragma warning( default : 4146 )
    #pragma warning( default : 4278 )
    

See Also

Tasks

How to: Control Add-Ins By Using the Add-In Manager

Walkthrough: Creating a Wizard

Concepts

Add-In Registration

Automation Object Model Chart

Other Resources

Creating Add-ins and Wizards