共用方式為


Expressions.DTE 屬性

取得最上層的擴充性物件。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
ReadOnly Property DTE As DTE
    Get
DTE DTE { get; }
property DTE^ DTE {
    DTE^ get ();
}
abstract DTE : DTE
function get DTE () : DTE

屬性值

型別:EnvDTE.DTE
DTE 物件。

備註

在 Visual Studio 中,DTE 物件是 Automation 模型的根物件,在其他物件模型中經常稱為「應用程式」。

範例

下列範例示範如何使用 DTE 屬性。

若要測試這個屬性:

  1. 目標應用程式必須包含類別 A。 Main 函式必須建立類別 A 的執行個體 (稱為 "a")。

  2. 建立類別 A 的執行個體並初始化它的成員變數之後,在 Main 函式中設定中斷點。

  3. 在偵錯模式執行目標應用程式。

  4. 當應用程式在中斷點停止時,請執行增益集。

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");
    owp.Activate();

    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: " + 
                     exps.Parent.CurrentProgram.Name);
    owp.OutputString("\nSecond expression: " + exps.Item(2).Name);
}
Shared Sub DTE(ByRef dte As EnvDTE.DTE)
    Dim exp As EnvDTE.Expression = dte.Debugger.GetExpression("a", True, 1)
    Dim exps As EnvDTE.Expressions = exp.DataMembers
    Dim str As String = vbCrLf
    str = "Expression count: " + exps.Count.ToString()
    str += vbCrLf + "Edition of the environment: " + exps.DTE.Edition
    str += vbCrLf + "The name of the current program: " + _
           exps.Parent.CurrentProgram.Name
    str += vbCrLf + "Second expression: " + exps.Item(2).Name
    MessageBox.Show(str, "Expression Test - Expressions Properties")
End Sub

.NET Framework 安全性

請參閱

參考

Expressions 介面

EnvDTE 命名空間

其他資源

HOW TO:編譯和執行 Automation 物件模型程式碼範例