Megosztás a következőn keresztül:


VSProject2.DTE Property

Gets the top-level extensibility object.

Namespace:  VSLangProj80
Assembly:  VSLangProj80 (in VSLangProj80.dll)

Syntax

'Declaration
ReadOnly Property DTE As DTE
'Usage
Dim instance As VSProject2 
Dim value As DTE 

value = instance.DTE
DTE DTE { get; }
property DTE^ DTE {
    DTE^ get ();
}
function get DTE () : DTE

Property Value

Type: EnvDTE.DTE
Returns a DTE object.

Implements

VSProject.DTE

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 Visual C#, or Visual J# project before running this example.

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
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

See Also

Reference

VSProject2 Interface

VSProject2 Members

DTE Overload

VSLangProj80 Namespace

DTE