简体   繁体   中英

how to get the selected error description in VS 2015

For previous versions of VS there were some ways to get the description of the error programmatically, that no longer work for Visual Studio 2015. I'm able to get the list of ALL the errors using some code like:

    dynamic selection = window.Selection;
    dynamic errItems = selection.ErrorItems;
     IEnumerable ienum = errItems as IEnumerable;
var enumerator = ienum.GetEnumerator();
    while (enumerator.MoveNext())
    {
        var first = enumerator.Current;
        dynamic dfirst = enumerator.Current;
        object objerr = first.GetType().GetProperty("Description",typeof(string)).GetValue(first, null);

        // PropertyInfo pi = first.GetType().GetProperty("Entry");//pi is null
        dynamic dfirst = enumerator.Current;
        // dynamic dentr = dfirst.Entry;//keeps throwing Binder exception
    }

My issue is that the "Entry" Property holds another property called " IsSelected " that I'm looking for and I can not reach, as you can see in the commented code above. Both dynamic and Reflection failed for me. According to the debugger that Entry property is of type Microsoft.VisualStudio.Shell.TableControl.Implementation.SnapshotTableEntryViewModel that is undocumented and most likely internal to VS 2015. How can I ca access Entry and IsSelected properties, or is there another workaround to get the description for the selected error only?

As of Visual Studio 2015 there's no such feature in Visual Studio Error List. The following is the closest official reply I could find from Microsoft:

在此输入图像描述

As per Microsoft( Visual Studio 2015 does not display Errors List window ):

Looking at the data you've provided, I believe you may have hit a known issue with the new Error List in Visual Studio 2015 Preview, which manifests itself when you attempt to double-click at the edge of a column to resize. The resize works, but the next time you restart Visual Studio the error list fails to load.

If you see this problem again, it's possible to work around it to get your error list back up and running again. This requires editing the registry (which should always be undertaken with caution, after backing up the registry)

The relevant key is HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\14.0\\NewTaskList

Follow these steps:

Close all running copies of Visual Studio on the affected machine Open RegEdit and locate the relevant key Delete the whole key (it will be regenerated when Visual Studio 2015 Preview re-starts) Re-start Visual Studio 2015, and the Error List should be available again We have fixed the underlying bug in later builds - watch for new releases of Visual Studio 2015. Thanks for taking the time to try Visual Studio 2015 Preview

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