简体   繁体   English

在Visual Studio 2015中调试时值不正确

[英]Incorrect value while debugging in Visual Studio 2015

Assume we have sample code (VS2015, WinForms, .Net 4.6.1): 假设我们有示例代码(VS2015,WinForms,.Net 4.6.1):

List<int> items = new List<int>();
private async Task test(int id)
{
    id = 1;
    int id_real = id;

    int index = items.FindIndex(x => x == id);
}

private async void button1_Click(object sender, EventArgs e)
{
    await test(0);
}

Now "the feature": 现在“特色”: 在此输入图像描述

How is that possible? 怎么可能? The interesting part - it is only Visual Studio watcher problem, runtime result remains correct. 有趣的部分 - 它只是Visual Studio观察者问题,运行时结果仍然正确。

For now I know it is only happens in VS2015, and cause of this behaviour - the last string in test method. 现在我知道它只发生在VS2015中,并导致这种行为 - 测试方法中的最后一个字符串。

Please enable "Use Managed Compatibility Mode" under TOOLS->Options->Debugging, and then re-debug your app, I think you would get the correct result in debugger windows as the VS2013 or VS2017. 请在TOOLS-> Options-> Debugging下启用“使用托管兼容模式”,然后重新调试您的应用程序,我认为您将在VS2013或VS2017的调试器窗口中获得正确的结果。

在此输入图像描述

Updated: 更新:

I also reported this issue to the connect report even if we could resolve this issue: 即使我们可以解决此问题,我也将此问题报告给连接报告:

https://connect.microsoft.com/VisualStudio/feedbackdetail/view/3135000/incorrect-value-while-debugging-in-visual-studio-2015 https://connect.microsoft.com/VisualStudio/feedbackdetail/view/3135000/incorrect-value-while-debugging-in-visual-studio-2015

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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