我试图在 Visual Studio 2015 错误列表窗口中获取所有错误,但在尝试通过 errors.Item(i) 调用访问 ErrorItem 时,我遇到了索引超出范围的异常。我是否缺少任何类型转换?
EnvDTE80.DTE2 dte2 = ServiceProvider.GetService(typeof(EnvDTE.DTE)) as DTE2);
ErrorItems errors = dte2.ToolWindows.ErrorList.ErrorItems;
for (int i = 0; i < errors.Count; i++)
{
ErrorItem item = errors.Item(i);
}
最佳答案
ErrorItems.Item
方法似乎需要一个绝对索引,从 1 开始,因此将循环更改为:
for (int i = 1; i <= errors.Count; i++)
那么它应该可以工作了。
关于c# - 调用 EnvDTE80.ErrorItems.item() 时获取 "Index was outside the bounds of the array.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42159829/