Export (0) Print
Expand All

Expressions.DTE Property

Gets the top-level extensibility object.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

DTE DTE { get; }

Property Value

Type: EnvDTE.DTE
A DTE object.

In Visual Studio, the DTE object is the root of the automation model, which other object models often call "Application."

The following example demonstrates how to use the DTE property.

To test this property:

  1. The target application must contain a class A. The function Main must create an instance of a class A called "a".

  2. Set a breakpoint in the function Main after an instance of class A is created and its member variables are initialized.

  3. Run the target application in the debug mode.

  4. When the application stops at the breakpoint, run the add-in.

public static void DTE(DTE dte)
    // Setup debug Output window.
    Window w = (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("DTE Property Test");

    EnvDTE.Expression exp = dte.Debugger.GetExpression("a", true, 1);
    EnvDTE.Expressions exps = exp.DataMembers;
    owp.OutputString("\nExpression count: " + exps.Count);
    owp.OutputString("\nEdition of the environment: " + exps.DTE.Edition);
    owp.OutputString("\nThe name of the current program: " + 
    owp.OutputString("\nSecond expression: " + exps.Item(2).Name);

© 2014 Microsoft