共用方式為


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 物件是 Automation 模型的根物件,Automation 物件在其他物件模型中經常稱為「應用程式」。

範例

若要將此範例當做增益集來執行,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例。開啟 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