Solution2.DTE 属性

获取顶级扩展性对象。

命名空间:  EnvDTE80
程序集:  EnvDTE80(在 EnvDTE80.dll 中)

语法

声明
ReadOnly Property DTE As DTE
    Get
DTE DTE { get; }
property DTE^ DTE {
    DTE^ get ();
}
abstract DTE : DTE
function get DTE () : DTE

属性值

类型:EnvDTE.DTE
一个 DTE 对象。

实现

_Solution.DTE

备注

在 Visual Studio 中,DTE 对象是自动化模型的根,其他对象模型通常将自动化模型称为“应用程序”。

示例

有关如何运行此外接程序代码的信息,请参见如何:编译和运行自动化对象模型代码示例

下面的示例查找并显示打开的解决方案中活动窗口的标题。

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)

   SolutionDTEExample(_applicationObject)
End Sub

Sub SolutionDTEExample(ByVal dte As DTE2)
    ' This add-in displays the caption of the active window,
    ' obtained through the DTE object. Open a solution in 
    ' Visual Studio before running this example.
    Try
        Dim soln As Solution2 = CType(_applicationObject.Solution, _
        Solution2)
        MsgBox _
        ("The caption of the active window, obtained through the DTE object, is: " & _
        vbCr & soln.DTE.ActiveWindow.Caption)
    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub
//you will need to add this reference to your project as well
using System.Windows.Forms;
public void OnConnection(object application,
 Extensibility.ext_ConnectMode connectMode, object addInInst,
 ref System.Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    SolutionCount((DTE2)_applicationObject);
}
public void SolutionCount(DTE2 dte)
{
    // This add-in displays the caption of the active window,
    // obtained through the DTE object. Open a solution in 
    // Visual Studio before running this example.
    Try
    {
        Solution2 soln = (Solution2)_applicationObject.Solution;
        MessageBox.Show
("The caption of the active window, obtained through the DTE object, is: "
 + soln.DTE.ActiveWindow.Caption);
    }
    catch(SystemException ex)
    {
        MessageBox.Show("ERROR: " + ex);
    }
}

.NET Framework 安全性

请参见

参考

Solution2 接口

DTE 重载

EnvDTE80 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例