问题
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?
回答1:
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!
回答2:
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.
回答3:
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.
回答4:
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"
回答5:
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
回答6:
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".
回答7:
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).
回答8:
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
回答9:
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
来源:https://stackoverflow.com/questions/28730100/visual-studio-2015-debugging-cant-expand-local-variables