Condividi tramite


VSProject2.DTE Property

Definition

Gets the top-level extensibility object.

public:
 property EnvDTE::DTE ^ DTE { EnvDTE::DTE ^ get(); };
public:
 property EnvDTE::DTE ^ DTE { EnvDTE::DTE ^ get(); };
[System.Runtime.InteropServices.DispId(3)]
public EnvDTE.DTE DTE { [System.Runtime.InteropServices.DispId(3)] get; }
[<System.Runtime.InteropServices.DispId(3)>]
[<get: System.Runtime.InteropServices.DispId(3)>]
member this.DTE : EnvDTE.DTE
Public ReadOnly Property DTE As DTE

Property Value

DTE

Returns a DTE object.

Implements

DTE
Attributes

Examples

To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples. Open a Visual Basic or Visual C# project before running this example.

[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}" );  
}   

Remarks

In Visual Studio, the DTE object is the root of the automation model, which other object models often call "Application".

Applies to