问题
Issue
Locals only displays this
variable while debugging, other local variables are not available in Locals or Watch but can be re-evaluated in Intermediate Window in Visual Studio
Brief
I'm debugging an Xunit test for some code I am writing. The library I am testing targets ASP.NET Core RC1. Here is my project.json
:
{
"authors": [ "Matthew Abbott" ],
"commands": {
"test": "xunit.runner.dnx"
},
"description": "Provides tests for the Fx.Content.Composer package",
"dependencies": {
"xunit": "2.1.0-rc1-build3168",
"xunit.runner.dnx": "2.1.0-rc1-build204",
"Fx.Content.Composer": ""
},
"frameworks": {
"dnx451": { },
"dnxcore50": {
"dependencies": {
"System.Runtime": "4.0.21-beta-23516"
}
}
},
"licenseUrl": "",
"projectUrl": "",
"tags": [ "" ],
"version": "1.0.0-*"
}
When debugging the unit test (I'm using Visual Studio's in built test features), I can set breakpoints, but the Locals/Watch windows don't allow me to inspect local variable declarations. I also do not get variable tooltips for those local variables.
If I copy and paste my statements into Intermediate, they are then added to scope, but I can't debug easily straight off the bat.
Things I've tried
- Ensured I am compiling in Debug mode
- Disabling JIT optimizations
- Reset my Visual Studio settings
Things of note
- I've recently installed Visual Studio 2015 Update 2
- I've restarted the IDE several times without success
- I've restarted my machine serveral times without success
- Not explicitly bound to a unit test debugging session - when I F5 to run, they fail there also
Any help would be greatly appreciated!
Update Based on Victor's comment, I tried stepping through into a method from that unit test, and initially a parameter is available in scope, but a variable defined further down is not.
回答1:
Update: Note this answer only applies to Visual Studio 2015 Update 2. If you are missing locals in any other release of Visual Studio, something else is going on. You can only install the hotfix patch over Visual Studio 2015 Update 2. Visual Studio 2015 Update 3 and later already have the fix.
Original Answer:
This looks like 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
来源:https://stackoverflow.com/questions/36455772/locals-missing-during-debugging-in-visual-studio-2015