ToolWindows.ErrorList 属性
获取 IDE 中显示的错误的列表。
命名空间: EnvDTE80
程序集: EnvDTE80(在 EnvDTE80.dll 中)
语法
声明
ReadOnly Property ErrorList As ErrorList
Get
ErrorList ErrorList { get; }
property ErrorList^ ErrorList {
ErrorList^ get ();
}
abstract ErrorList : ErrorList
function get ErrorList () : ErrorList
属性值
类型:EnvDTE80.ErrorList
可针对各个错误枚举的错误列表。
示例
此外接程序示例打开**“错误列表”**窗口,并在消息框中显示错误(如果存在的话)。 在运行此示例之前,生成一个包含一些错误的项目。
有关如何作为外接程序运行此示例的更多信息,请参见 如何:编译和运行自动化对象模型代码示例。
Imports EnvDTE
Imports EnvDTE80
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)
GetErrorList(_applicationObject)
End Sub
Public Sub GetErrorList(ByVal dte As DTE2)
Dim myErrors As ErrorList
Dim count As Integer
Dim aString As String
aString = ""
_applicationObject.ExecuteCommand("View.ErrorList", " ")
myErrors = _applicationObject.ToolWindows.ErrorList
count = myErrors.ErrorItems.Count
If count <> 0 Then
For k As Integer = 1 To count
aString &= _
(myErrors.ErrorItems.Item(k).Description.ToString() & vbCr)
Next k
MsgBox(aString)
Else
MsgBox("There are no items in the error list.")
End If
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application,
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
GetErrorList(_applicationObject);
}
public void GetErrorList(DTE2 dte)
{
ErrorList myErrors;
int count;
String aString = null;
_applicationObject.ExecuteCommand("View.ErrorList", " ");
myErrors = _applicationObject.ToolWindows.ErrorList;
count = myErrors.ErrorItems.Count;
if (count != 0)
{
for (int i = 1; i <= count; i++)
{
aString +=
(myErrors.ErrorItems.Item(i).Description.ToString() + "\n");
}
MessageBox.Show(aString);
}
else
{
MessageBox.Show("There are no items in the error list.");
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。