Invalid value when debugging in Visual Studio 2015

Let's assume we have some sample code (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 "function": enter image description here

How is this possible? The interesting part is this is just a Visual Studio observer issue, the execution result remains correct.

So far I know this only happens in VS2015 and the reason for this behavior is the last line in the test method.

+3


source to share


1 answer


Enable "Use Managed Compatibility Mode" under TOOLS-> Options-> Debugging and then re-debug your application, I think you will get correct result in debugger windows like VS2013 or VS2017.

enter image description here

Updated:



I also reported this issue in the connectivity report, even if we could fix this issue:

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

+2


source







All Articles