Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Reference.DTE Property

Gets the top-level extensibility object.

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

DTE DTE { get; }

Property Value

Type: EnvDTE.DTE
Returns a DTE object.

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

public void DTEExample(DTE2 dte)
{
    string msg = "The current Output Window object belongs to the ";
    OutputWindow output = dte.ToolWindows.OutputWindow;

    if (IsMacrosIDE(output.DTE))
        MessageBox.Show(msg + "macros IDE.");
    else
        MessageBox.Show(msg + "main IDE.");

    output = ((DTE2)dte.MacrosIDE).ToolWindows.OutputWindow;

    if (IsMacrosIDE(output.DTE))
        MessageBox.Show(msg + "macros IDE.");
    else
        MessageBox.Show(msg + "main IDE.");
}

bool IsMacrosIDE(DTE ide)
{
    bool val = true;

    try
    {
        // The MacrosIDE property throws an exception if ide 
        // is not the main DTE object.
        if (ide.MacrosIDE != null)
            val = false;
    }
    catch (Exception ex)
    {
    }

    return val;
}

Show:
© 2015 Microsoft