简体   繁体   中英

How can I get the Error Code from Error List in VS 2015/2017 with DTE? Or other ways can get error code?

I want to extend the Error List in Visual studio 2015/2017,I only use the DTE can get the ErrorItem however the ErrorItem don'e contain the ErrorCode just like below, how can i get the error code? Thanks in advance! 在此处输入图像描述

Yup, I also had this. Might be too late to help, but here you go:

    var errorList = _dte.ToolWindows.ErrorList as IErrorList;
    // placed in dictionary for easy access later
    var entries = (errorList?.TableControl.Entries ?? Enumerable.Empty<ITableEntryHandle>())
        .Select((e, i) => new { Entry = e, Index = i + 1 })
        .ToDictionary(it => it.Index, it => it.Entry);

    var errors = errorList.ErrorItems;
    for (int i = 1; i <= errors.Count; i++)
    {
        ErrorItem error = errors.Item(i);
        entries[i].TryGetValue("errorcode", out var errorCode);
        var item = new
        {
            error.Column,
            error.Description,
            error.ErrorLevel,
            error.FileName,
            error.Line,
            error.Project,
            Code = errorCode
        };
    }

it works on my solution which was build on visual studio 2022

var dte = (EnvDTE.DTE)System.Activator.CreateInstance(t, true) as EnvDTE80.DTE2;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM