46

I'm using Visual Studio 2015 preview, and I'm trying to debug my project. I was using VS 2012 previously, and depended largely on being able to hover over and expand local variables to look at their values. I'm trying to do this in 2015 now, but when I hover over a variable, the box that shows up only says "(local variable) Classname variablename" (e.g. "(local variable) String title"). There is no expand button, and it doesn't show the value of the variable in the box.

Is there a setting I have to change in order to be able to hover over variables and expand them?

Erica Stockwell-Alpert
  • 4,624
  • 10
  • 63
  • 130
  • 1
    Can you also, please, try updating to the latest CTP? There is a chance this might be a known issue that was already fixed. If it still reproes, please get us a repro project and steps (either connect or the feedback tool that's integrated in VS now). Thanks! – Maria Mar 06 '15 at 23:48
  • Also getting this in VS2019 Preview but solutions don't exist anymore, please let me now if anyone knows a solution working for VS2019 – jsmars Sep 30 '19 at 07:24

10 Answers10

92

It might be a bug. Please file a Connect bug with a repro if you have one.

In the meantime, you might be able to workaround the problem by setting the debugger options to use the legacy debug engine: Tools -> Options -> Debugging -> General: check both "Use the legacy C# and VB expression evaluators" and "Use Managed Compatibility Mode".

That workaround has worked for me every time. But please, do still file the bugs!

Options window

SerjG
  • 3,325
  • 3
  • 30
  • 30
Andrew Arnott
  • 80,040
  • 26
  • 132
  • 171
  • 5
    Unfortunately this didn't work for my issue, which is similar, but not the exact same as the OP. In my case, hovering over my variables only works for some and not others in VS 2015. I will post a solution/work around when I find one. – ajpetersen Aug 07 '15 at 15:10
  • Well that was quick, I found an article on msdn here: http://bit.ly/1Ir4yFv that suggested resetting the settings in VS. – ajpetersen Aug 07 '15 at 15:15
  • 2
    I think that "Use Managed Compatibility Mode" is enough. Need to make a more detailed testing but after this option checked I was able to see the local variable debugging value – SerjG Mar 24 '16 at 22:29
  • Thanks a ton! I had a similar problem (http://stackoverflow.com/questions/36353390/viisual-studio-2015-not-finding-variables-in-scope-after-update-2) and this worked for me. But I can't help but wonder, what am I losing out on when applying these changes? – Christofer Ohlsson Apr 01 '16 at 13:23
  • This 'fix' worked for me (VS2015 update 2), but we loose some new debugging features when doing it so. I reported the issue on ms connect – Joao Costa Apr 19 '16 at 15:21
  • 11
    @AlexLogan this issue still happens in VS2015 update 3! – eestein Jul 21 '16 at 15:29
  • confirmed it still occurs, none of those workarounds works for me :( –  Dec 04 '16 at 20:39
  • @eestein I found a solution vs2015 update 3. Try to remove "debugType": "portable" from project.json – azDev Dec 07 '16 at 13:06
  • @eestein what was your case? – azDev Dec 07 '16 at 13:10
  • @azDev "regular" VS project, not .net core or whatever is using project.json :) – eestein Dec 07 '16 at 14:02
  • Thank you! It's quite annoying that the default setting for "Use managed compability mode" is the turned-off state – florien Apr 14 '17 at 02:39
  • Frankly the usability of the linked site makes it nearly impossible to file a bug. VS 2017 continues to exhibit this bug/stops showing locals until reset settings which is a bit ridiculous since nothing was changed. - this "option" setting does not help – Mark Schultheiss Sep 21 '17 at 12:28
  • Legacy # and VB expression evaluator is deprecated in VS2017 – st35ly Apr 08 '18 at 22:18
  • 2020 just called: "Microsoft Connect Has Been Retired". On the plus side, I can hover over a literal and it shows me the value! Otherwise, useless. – gbarry Jun 26 '20 at 01:09
20

I had a similar issue where when I hovered over my local variable, some would let me dive deeper and some would not show anything. After some digging I found an article on msdn here, that suggested resetting the settings in VS. Once I did that, I got a notice that I was running in Release mode and that some debugging features may not be available. Once I changed to Debug mode, everything worked like normal.

Hopefully this will work for you as well.

Matt
  • 179
  • 7
ajpetersen
  • 639
  • 8
  • 17
10

As described here, you need to enable the check “Suppress JIT optimizations on module load (Managed only)” in Debug --> Options --> Debugging --> General.

You need also to remove the "Optimize code" flag in the properties of your projects.

ilCosmico
  • 1,319
  • 15
  • 26
7

I was having a similar issue in VS2015 where some variables would show the debug values, others wouldn't show anything when hovered over.

Enabling the following setting from Andrew Arnott solved my issue: Tools -> Options -> Debugging -> General: "Use the legacy C# and VB expression evaluators"

Jon Knopp
  • 111
  • 1
  • 8
2

In my case the Solution Configuration was set to Debug but the Solution platform was set to Mixed Platforms. Setting the Solution Platform to Any CPU fixed the issue

enter image description here

1

I've discovered the way to break into native code and have access to STL containers' content when debugging using CLI :

Tools\Options...\Debugging\General : uncheck 'Use Managed Compatibility Mode' (YES! UNCHECK IT!)

In the native code, instead to add breakpoints, just add this :

assert(false);

When breaking against the shores, just click either 'Retry' to debug or 'Ignore' to continue.

Happy debugging with Visual Studio 2015 :)

Kochise

Kochise
  • 504
  • 5
  • 10
1

I found that simply changing the combobox with "Release and debug" back to debug allowed me to see the expansion of variables when debugging my code again.

This newest solution worked for VS 2017 on my home PC.

My work PC was able to show this expansion in 2017 after I did the "Build >> Clean Solution option and will even work when the combobox is set to "Release".

Best of luck to anyone else that wants this wonderful debugging help form VS. I hope that by using one of these methods you're able to get back to "normal".

0

I had a project that was using minified JavaScript files and wanted to use the TypeScript files for debugging. I put the unminified JavaScript and the associated TypeScript into the project and changed the references to use the normal JavaScript file and not the minified one. My break points were hit in the TypeScript file but I was not getting hover information (surprisingly it looked like adding the object/variable as a watch seemed to work).

To fix I just excluded the minified JavaScript from the file from the project and included the JavaScript. (The TypeScript file I left excluded).

spacebread
  • 503
  • 7
  • 19
0

This worked for me in VS2017(My VS is in german so the tab names could be a bit different):

Project -> Properties -> C/C++ -> Code Generation -> RunTimeErrorCheck->\RTC

Also try deactivating the optimization option since making your code faster could mean not being able to watch the values of your local variables:

Project -> Properties -> C/C++ -> Optimization -> Disabled

dalapiz
  • 11
  • 4
-1

I'm working on a 'Debug' configuration that have no optimization set, so I repeat :

Using managed compatibility : can use breakpoint, but cannot watch values

Not using managed compatibility : cannot use breakpoint, but can watch values

Hence using the assert as breakpoint when not using managed compatibility allows you to both stop where needed AND watch values.

Try it.

I provided you with my trick because I'm just facing the same issue right now, 1w before final delivery. And MS pretend planning a complete fix for 2016 in update 2 is just unbearable.

BTW, this makes another perfect 'break' :

int *p = NULL, i = 1 / *p;

Kochise

Kochise
  • 504
  • 5
  • 10