Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2015 Update 2 - Variable does not exist when debugging, why?

I'm using VS 2015 Update 2 with an asp.net 5 web project configured for debug mode. When I run the project with F5 to debug it and hit a break point, some variables can not be observed in the watch window even when they are in scope. Further, if I hover over such variables no value is displayed.

If I use the same visual studio to create an empty web project and add a webform and place the code in the load method, the debugger works fine. That is to say, I can see the variables in the watch window and I can see their values by hovering over them. I glean from this that the root cause of the issue is not VS2015 Update 2 but rather something to do with the project or solution configuration, perhaps specific to asp.net 5 web projects.

I've scoured the web for answers and similar problems happen when trying to debug compiler optimized code. But I am running the solution in debug mode. Any suggestions?

Screenshot of error

I am aware of Variable does not exist in the current context while debugging but it applies to a different version of visual studio and the solutions offered there do not fix my issue.

like image 346
RonC Avatar asked Apr 06 '16 22:04

RonC


1 Answers

I had the same problem. Eventually I noticed that some settings are different after update 2.

You need to go to Tools --> Options --> Debugging --> General and then check "Use Managed Compatibility Mode".

That worked for me.

like image 76
Danny van der Kraan Avatar answered Nov 04 '22 17:11

Danny van der Kraan