unable to evaluate expression whilst debugging unable to evaluate expression whilst debugging asp.net asp.net

unable to evaluate expression whilst debugging


I faced it today with VS2013.

Goto Tools --> Options --> Debugging --> General --> Scroll to the bottom for "Use Managed Compatibility Mode" and Select the option.

Screenshot from the blog(url below):enter image description hereRestart you debugging. Hope it helps others.

What Helped Me is below!


The C# debugging engine relies heavily on the CLR debugger in order to evaluate expressions. That message indicates that the CLR is in a state in which it is unable to perform simple evaluations and the reasons for that can include the following

  • a local variable is optimized away
  • the thread is stopped in a GC unsafe point
  • a previous function call caused the debugger to get into a bad state and hence further evaluations simply aren't possible


Some of these options change over time - and top rated solutions in other answers don't seem to all exist any more - searching the options dialog can help.

Right now for a ASPNET Core project I found this, and enabling it seems to be helping:

enter image description here

Suppress JIT optimization on module load (Managed only): Disables the JIT optimization of managed code when a module is loaded and JIT is compiled while the debugger is attached. Disabling optimization may make it easier to debug some problems, although at the expense of performance. If you are using Just My Code, suppressing JIT optimization can cause non-user code to appear as user code ("My Code"). For more information, see JIT optimization and debugging.

If it doesn't seem to help I'd suggest turning it off again.