VSProject2.DTE Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Returns a DTE object.
Implements
- 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".