VSProject2.DTE Property
Gets the top-level extensibility object.
Namespace: VSLangProj80
Assembly: VSLangProj80 (in VSLangProj80.dll)
Syntax
'Declaration
ReadOnly Property DTE As DTE
DTE DTE { get; }
property DTE^ DTE {
DTE^ get ();
}
abstract DTE : DTE with get
function get DTE () : DTE
Property Value
Type: EnvDTE.DTE
Returns a DTE object.
Remarks
In Visual Studio, the DTE object is the root of the automation model, which other object models often call "Application".
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}" );
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.