Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio debugger shows wrong value (null where there should be a value)

I'm stuck, why does this happen? The code literally says that entity != null but the debugger thinks it's null. What is going on?

visual studio screenshot - debugging

I already changed to x86, recompiled, cleaned, even restarted the pc. And the code was always like this, there is no version where the if statement was different. And if I continue I don't get a null-pointer exception.

like image 830
Wouter Schut Avatar asked Nov 11 '15 21:11

Wouter Schut


People also ask

How do I see variable values in Visual Studio debugging?

Hover over a variable to see its value. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.

How do I Deattach debugger in Visual Studio?

When debugging is complete, you can detach the debugger from the process by clicking Debug, and then clicking Stop Debugging in Visual Studio.


1 Answers

I experienced the same problem when there was variable with same name declared earlier in the method. In that case debugger would only 'notice' first variable. It has no impact on actual code execution.

like image 120
Artur Krajewski Avatar answered Oct 15 '22 12:10

Artur Krajewski