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 对象是自动化模型的根,其他对象模型常常称之为“应用程序”。

示例

下面的示例演示如何使用 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 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例