DTE Interface
The top-level object in the Visual Studio automation object model. Use this object for functionality and refer to _DTE for this object’s documentation.
Namespace: EnvDTE
Assembly: EnvDTE (in envdte.dll)
Assembly: EnvDTE (in envdte.dll)
The DTE object is provided by the OnConnection method that you implement when you create an Add-in. The DTE object is the Application object in Visual Basic.
To access project-specific properties such as VBProjects or CSharpProjects, use the syntax DTE.GetObject("VBProjects").
For details about referencing the EnvDTE namespace and the DTE object, see Referencing the DTE Object.
Sub DTEExample() Dim objTextDoc As TextDocument Dim objEP As EditPoint ' Create a new text document. DTE.ItemOperations.NewFile("General\Text File") ' Get a handle to the new document. Set objTextDoc = DTE.ActiveDocument.Object("TextDocument") Set objEP = objTextDoc.StartPoint.CreateEditPoint ' Create an EditPoint and add some text. objEP.Insert "A test sentence." End Sub
DTE is a lifetime controller
Like the Solution object, DTE is used to control the lifetime of the IDE when being used programmatically. When the number of external (references through a out of process controller) COM references on the DTE object, plus the number of external COM references on the Solution object, plus 1 if the DTE.UserControl property is set to true, becomes 0, then Visual Studio will close. If you are programming Visual Studio with an out of process COM controller, then you need to keep this sum of references above 0 to make sure that Visual Studio does not close.
- 6/16/2006
- Craig Skibo - MSFT