Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

variable values not showing during debug vs 2019 16.2.4

I have a break point set after I have assigned a value to a local variable. The name of the variable remains grayed out, and I can't see its value when I hover over it. This was working find but has suddenly stopped.

As shown in the code below, I have set two break points, one where I add together two local variables, and one when I instantiate a form. The debugger does not halt at the first break point, but does at the second. When I hover over any of the local variables, I get not recognition of the variable nor its value.

int testVariable = 1;
int test2 = 3;
int test3 = 0;
test3 = testVariable+test2; //this is where the breakpoint is - note test3 is grayed out
MainForm main = new MainForm(); // this where the second breakpoint is which does work
main.Show();
like image 295
cwmartz Avatar asked Sep 08 '19 05:09

cwmartz


People also ask

How can I see the variable value while debugging in Visual Studio 2019?

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 show local variables in debugging?

Locals While debugging you can enable 'Locals' which will show you all variables in the current stack frame. Go to menu Debug->Windows->Locals to make it appear. Watch Although it is a little manually you also can use 'Watch' you can drag and drop any variable to this window or right click then add to watch.


2 Answers

This was working find but has suddenly stopped.

Did you make any changes to your project recently? Nothing is special with your code, I assume this is an issue with your settings or extensions. You can try steps below to resolve this issue:

  1. You can try restarting VS and rebuilding the project.

  2. If it persists, please reset all your debug-related options (Tools -> Import and Export settings -> Reset all settings ->No, just reset...).

  3. If it not works, go Tools -> Options -> Debugging -> General to check both "Use the legacy C# and VB expression evaluators" and "Use Managed Compatibility Mode".

Also, according to this document, please avoid debugging optimized code, you can enable the "Suppress JIT optimizations on module load (Managed only)" option to check if it helps.

like image 155
LoLance Avatar answered Sep 29 '22 19:09

LoLance


The problem I had that I was executing the application in release mode, changing it to Debug resolved the issue.

like image 29
Ramzi Hammouda Avatar answered Sep 29 '22 21:09

Ramzi Hammouda