BuildManager.DTE 属性
获取顶级扩展性对象。
命名空间: VSLangProj
程序集: VSLangProj(在 VSLangProj.dll 中)
语法
声明
ReadOnly Property DTE As DTE
DTE DTE { get; }
property DTE^ DTE {
DTE^ get ();
}
abstract DTE : DTE with get
function get DTE () : DTE
属性值
类型:DTE
返回 DTE 对象。
备注
在 Visual Studio 中,DTE 是自动化模型的根,其他对象模型常常将自动化模型称为“应用程序”。
示例
Sub DTEExample(ByVal dte As DTE2)
Dim msg As String = _
"The current Output Window object belongs to the "
Dim output As OutputWindow = dte.ToolWindows.OutputWindow
If IsMacrosIDE(output.DTE) Then
MsgBox(msg & "macros IDE.")
Else
MsgBox(msg & "main IDE.")
End If
output = CType(dte.MacrosIDE, DTE2).ToolWindows.OutputWindow
If IsMacrosIDE(output.DTE) Then
MsgBox(msg & "macros IDE.")
Else
MsgBox(msg & "main IDE.")
End If
End Sub
Function IsMacrosIDE(ByVal ide As DTE) As Boolean
Dim val As Boolean = True
Try
' The MacrosIDE property will throw an exception if ide
' isn't the main DTE object
If IsNothing(ide.MacrosIDE) = False Then
val = False
End If
Catch ex As Exception
End Try
Return val
End Function
public void DTEExample(DTE2 dte)
{
string msg = "The current Output Window object belongs to the ";
OutputWindow output = dte.ToolWindows.OutputWindow;
if (IsMacrosIDE(output.DTE))
MessageBox.Show(msg + "macros IDE.");
else
MessageBox.Show(msg + "main IDE.");
output = ((DTE2)dte.MacrosIDE).ToolWindows.OutputWindow;
if (IsMacrosIDE(output.DTE))
MessageBox.Show(msg + "macros IDE.");
else
MessageBox.Show(msg + "main IDE.");
}
bool IsMacrosIDE(DTE ide)
{
bool val = true;
try
{
// The MacrosIDE property will throw an exception if ide
// isn't the main DTE object
if (ide.MacrosIDE != null)
val = false;
}
catch (Exception ex)
{
}
return val;
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。