10

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

Visual Studio Debugging Window with Missing Locals

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.

Partial missing locals?

Matthew Abbott
  • 60,571
  • 9
  • 104
  • 129
  • I've seen this before. In my case, it was only the first method in which the breakpoint was hit that was missing the locals. If I would step in another method, locals would show up. If that's the case, then you might have to reinstall VS - that's what worked for me – Victor Hurdugaci Apr 06 '16 at 16:03
  • @VictorHurdugaci I tried stepping through to a method, and initially my parameters are available in **Locals**, but if I step through, a local declaration is not available. I've attached an updated screenshot – Matthew Abbott Apr 06 '16 at 16:13
  • 1
    Running on debug or release? – Victor Hurdugaci Apr 06 '16 at 17:25
  • As detailed above - I'm always checking I'm in Debug mode. Just re-installing VS and seeing if that fixes it... – Matthew Abbott Apr 07 '16 at 06:00
  • Re-install didn't fix the issue :-/ – Matthew Abbott Apr 07 '16 at 08:19
  • It is a known bug - http://stackoverflow.com/questions/28730100/visual-studio-2015-debugging-cant-expand-local-variables. – Lukasz Pyrzyk Apr 07 '16 at 08:21
  • Thanks! That actually seemed to fix it - I had stumbled across that OS question previously, but as the question author was using 2015 Preview, and we're now on 2015 Update 2, I would have hoped this would have been solved - I'll progress through a Connect bug and see if its actively being fixed – Matthew Abbott Apr 07 '16 at 08:37

1 Answers1

11

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

Patrick Nelson - MSFT
  • 3,182
  • 1
  • 14
  • 13
  • I had OP's issue since Update 2 but could not even see variables in the immediate window (while it seems he could). This patch fixed the issue for me! – Christopher Apr 11 '16 at 23:11
  • @Chris I could only get the variables in Intermediate if I redeclared them there, they wouldn't evaluate if I didn't. Installed the patch but haven't tested yet – Matthew Abbott Apr 15 '16 at 07:39
  • 3
    I have the same issue in VS 2015 Update 3 and can't install that Update 2 patch for it. – George Helyar Feb 17 '17 at 08:53
  • Yes me too I have update 3 and can not install this fix. It is really annoying – AFgone Sep 23 '17 at 13:05