VSProject2.DTE 属性

获取顶级扩展性对象。

命名空间:  VSLangProj80
程序集:  VSLangProj80(在 VSLangProj80.dll 中)

语法

声明
ReadOnly Property DTE As DTE
DTE DTE { get; }
property DTE^ DTE {
    DTE^ get ();
}
abstract DTE : DTE
function get DTE () : DTE

属性值

类型:EnvDTE.DTE
返回 DTE 对象。

备注

在 Visual Studio 中,DTE 对象是自动化模型的根,其他对象模型通常将自动化模型称为“应用程序”。

示例

若要将此示例作为外接程序运行,请参见如何:编译和运行自动化对象模型代码示例。 在运行此示例之前,请打开一个 Visual Basic 或 Visual C# 项目。

[Visual Basic]

Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    applicationObject = CType(application, DTE2)
    addInInstance = CType(addInInst, AddIn)
    DTESample(applicationObject)
End Sub
Sub DTESample(ByVal dte As DTE2)
    Dim aProject As Project
    Dim aVSProject As VSProject2
    aProject = applicationObject.Solution.Projects.Item(1)
    aVSProject = CType(applicationObject.Solution.Projects.Item(1)._
    Object, VSProject2)
    ' Reach the DTE object through a VSProject object.
    aVSProject.Project.DTE.ItemOperations.NewFile _
    ("General\Text File", "MyTextFile")
End Sub

[C#]

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    DTESample(((DTE2)applicationObject));
}

public void DTESample(DTE2 dte)
{
    Project aProject = null;
    VSProject2 aVSProject = null;
    aProject = applicationObject.Solution.Projects.Item(1);
    aVSProject = ((VSProject2)
( applicationObject.Solution.Projects.Item(1).Object));
    // Reach the DTE object through a VSProject object.
aVSProject.Project.DTE.ItemOperations.NewFile
(@"General\Text File","", "{00000000-0000-0000-0000-000000000000}" );
} 

.NET Framework 安全性

请参见

参考

VSProject2 接口

DTE 重载

VSLangProj80 命名空间

DTE