共用方式為


Reference3.DTE 屬性

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

命名空間:  VSLangProj80
組件:  VSLangProj80 (在 VSLangProj80.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 物件。

實作

Reference2.DTE

備註

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

範例

此範例會示範如何從 Reference3 物件抵達 DTE 物件。 開啟 Visual Basic 或 Visual C# 專案,再執行此範例。 若要將此範例當做增益集來執行,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例

新增的參考 (adodb.dll) 之預設路徑為:<installation root>\Program Files\Microsoft.NET\Primary Interop Assemblies。 以這個或另一個適當的檔案路徑取代範例中的 <file path>。

Imports VSLangProj
Imports VSLangProj2
Imports VSLangProj80
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)
    ReachDTEObject(applicationObject)
End Sub
Public Sub ReachDTEObject(ByVal dte As DTE2)
    ' The first project is a Visual Basic or C# project.
    Dim vsProject As VSProject2 = _
    CType(applicationObject.Solution.Projects.Item(1).Object, _
    VSProject2)
    Dim aRef As Reference3
    ' Replace the <file path> with an actual file path.
    aRef = CType(vsProject.References.Add_
    ("<file path>\adodb.dll"), Reference3)
    MsgBox("Added a reference named: " & aRef.Name.ToString())
    MsgBox("Name of the containing solution for " & aRef.Name & _
    vbCr & "reached through the DTE object is: " & vbCr & _
    aRef.DTE.Solution.FullName.ToString())
End Sub
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application,
 ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    ReachDTEObject(((DTE2)applicationObject));
}
public void ReachDTEObject(DTE2 dte)
{
    // The first project is a Visual Basic or C# project.
    VSProject2 vsProject = 
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
    Reference3 aRef = null;
    // Replace <file path> with an actual file path.
    aRef = (Reference3)vsProject.References.Add
((@"<file path>\adodb.dll"));
    MessageBox.Show ("Added a reference named: " 
+ aRef.Name.ToString());
    MessageBox.Show("Name of the containing solution for " 
+ aRef.Name + "\n" + "reached through the DTE object is: " + "\n" 
+ aRef.DTE.Solution.FullName.ToString());
}

.NET Framework 安全性

請參閱

參考

Reference3 介面

DTE 多載

VSLangProj80 命名空間