Reference3.DTE-Eigenschaft

Ruft das Erweiterbarkeitsobjekt der obersten Ebene ab.

Namespace:  VSLangProj80
Assembly:  VSLangProj80 (in VSLangProj80.dll)

Syntax

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

Eigenschaftswert

Typ: EnvDTE.DTE
Ein DTE-Objekt.

Implementiert

Reference2.DTE

Hinweise

In Visual Studio ist das DTE-Objekt das Stammobjekt des Automatisierungsmodells, das in anderen Objektmodellen häufig als "Application" bezeichnet wird.

Beispiele

In diesem Beispiel wird veranschaulicht, wie über ein Reference3-Objekt auf das DTE-Objekt zugegriffen wird. Öffnen Sie ein Visual Basic- oder ein Visual C#-Projekt, bevor Sie dieses Beispiel ausführen. Um dieses Beispiel als Add-In auszuführen, informieren Sie sich unter Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell.

Der Standardpfad für den hinzugefügten Verweis (adodb.dll) lautet: <Stammpfad der Installation>\Programme\Microsoft.NET\Primary Interop Assemblies. Ersetzen Sie <file path> im Beispiel durch diesen oder einen anderen geeigneten Dateipfad.

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-Sicherheit

Siehe auch

Referenz

Reference3 Schnittstelle

DTE-Überladung

VSLangProj80-Namespace