Share via


Reference3.DTE, propriété

Obtient l'objet d'extensibilité de niveau supérieur.

Espace de noms :  VSLangProj80
Assembly :  VSLangProj80 (dans VSLangProj80.dll)

Syntaxe

'Déclaration
ReadOnly Property DTE As DTE
DTE DTE { get; }
property DTE^ DTE {
    DTE^ get ();
}
abstract DTE : DTE with get
function get DTE () : DTE

Valeur de propriété

Type : DTE
Objet DTE.

Notes

Dans Visual Studio, l'objet DTE est à la base du modèle Automation que les autres modèles objet appellent souvent "Application".

Exemples

Cet exemple montre comment atteindre l'objet DTE à partir d'un objet Reference3. Ouvrez un projet Visual Basic ou Visual C# avant d'exécuter cet exemple. Pour exécuter cet exemple comme un complément, consultez Comment : compiler et exécuter les exemples de code du modèle objet Automation.

Chemin d'accès par défaut de la référence ajoutée (adodb.dll) dans : <racine d'installation>\Program Files\Microsoft.NET\Primary Interop Assemblies. Remplacez <chemin d'accès au fichier> dans l'exemple, par celui-ci ou tout autre chemin approprié.

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());
}

Sécurité .NET Framework

Voir aussi

Référence

Reference3 Interface

VSLangProj80, espace de noms