问题
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?
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.
回答1:
This is a bug that was introduced in Visual Studio 2015 Update 2. Essentially the debugger is unable to inspect local variables in dynamic modules. We released a hotfix for it today. You can download the patch here. Documentation for the patch is here. Let me know if the patch does not fix your particular scenario.
Thanks!
-Patrick Nelson
回答2:
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.
来源:https://stackoverflow.com/questions/36463286/vs-2015-update-2-variable-does-not-exist-when-debugging-why