Search code examples
visual-studio-debugging

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();

Solution

  • 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.