Instantiated local variable is displayed as null in the debug inspector

I am having a strange problem while debugging some asynchronous code in visual studio: enter image description here

As you can see, I have a for loop that iterates over an IEnumerable with 9 instances of objects in it (horrible name I know, not my DB ...) i

is 0 in this case, so elementAt has to put the first element into a variable betaling

. It does the right thing and this code runs flawlessly, but it shows up as null in the debugger:

enter image description here

When I continue to debug everything is fine, the variable is betaling

used in a few lines of code and saved to the DB correctly, so this is just my debug inspector showing the object as null. This is pretty annoying when you are debugging since you can't see anything. I suspect this should do something with an async await. Several databases are waiting before this cycle. And keeping an object betaling

in a loop is also a wait method. However, when I try to reproduce this behavior in a test project, everything works fine.

I know that you might have problems accessing properties from other threats in asynchronous methods and I am calling this code from the VM, but why can I see the list? I suspect this is a bug, and if not, it is of course a weird "function" that can keep track of lines of code but fail to check some properties.

I tested this in VIsual Studio 2012 and 2013, same behavior in both.

+3


source to share


1 answer


I can see this for both VS 2015 Update 3 and VS 2017.

As a work-around, I found that with my mouse hover over / click Run Run for this, keeping the instance value where the keyboard accelerator (“Ctrl + Shift + F10”) will exclude the value specified in the instance.



VS mouse hover

+1


source







All Articles