I have the following C# variable and code:
string word;
...
if (word.Length > width)
...
During debugging in Visual Studio 2010, the Locals window shows word but word.Length is only available as a DataTip. Why is this, and is there a way to have the Locals window show such attributes as Length?
I am on Windows 7, Visual Studio 2010.
Because the Locals window show only local variables in current stack frame. Current stack frame can be selected in the Call Stack window.
To get the value of "word.Length" expression, you can use the Autos window or Watch window. The Autos window displays variables used in the current statement and the previous statement. In Watch window you should manually add the "word.Length" expression.
Related
I feel a bit silly about this, but I seem to have accidentally hidden the variables section for debug mode in Visual Studio Code, and can't figure out how to get it back.
The debugger is starting ok (using node.js for debuggging a js file), and I can see Watch, Call Stack, and Breakpoints - but no Variables window. Have attached a screenshot to show the layout.
screeny of VS Code window
Press Ctrl + P to open the "Go to File..." menu and type in view Variables and press Enter. This will show the variables view again.
I am using Xamarin Studio 5.10.2. In the debugger I can set breakpoints, run, and the debugger does stop at the breakpoints. However, it does not bring the location of the breakpoint into view. I know the breakpoint is hit because it displays the call stack in its window. When I double-click on the top item of the call stack, the source file is opened and the line pending execution is displayed in the center of the editor.
I can step along execution and see the lines highlight as it goes through them, but it never re-centers the current line and it will step right off the bottom of the window. (I can keep it in view by either manually scrolling or double-clicking the top line of the call stack.)
In Visual Studio (with which I'm much more familiar), the pending execution line is displayed automatically when the breakpoint is hit---no need to double-click on the call stack. Is there a way to get this behavior in Xamarin Studio?
When debugging XML, it's a pain the butt to constantly click on the Text/XML visualizers in the Watch Window to see the full value of an XML string variable. The "Watch" windows in Visual Studio seem to be constrained to one line.
Is there a way to constantly "watch" the value of a multi-line variable when debugging? Doesn't have to be in a watch window i suppose, but I want to see the value of an XML string, and the visualizer boxes are modal.
It's not very pretty, but one way I have dealt with that is to put the string address in a memory window, which can show text characters. Open one of the memory windows from the Debug menu: Debug\Windows\Memory. You can then type in the address or the variable name or just double click on the variable and "drag" it up to the address field of the memory window.
What you could do is change the autoexp.dat so it will display the hash of the string first, so at least you know when the string changes. That way you don't need to open the visualizer box as often. Of course this will not work when the multi-line string is continually being updated.
I know this question is asking about Visual Studio 2010, but in Visual Studio 2013, you can right-click on the string variable row in the Autos/Locals/Watch pane and select Add Parallel Watch. This will give you a non-modal, multi-line view of the string variable value.
I am new and stupid. I closed this window:
How this window is called and how to activate it. Make it pop up.
It is the Locals window.
You will find it under Debug -> Windows.
Alternatively, use the keyboard shortcut Ctrl + D + L.
It is only available during a debugging session and is not available on Express editions.
Go to the Debug menu then windows then locals and it will show up. You must be in the middle of debugging to have it show in the list.
The Locals window comes up with you start debugging (hit F5). If you need it back, go to Debug > Windows > Locals while debugging.
Note, you can also get it back if you click Windows > Reset Window Layout (which I've had to use on occasion when windows get really messed up!) Be warned that this will erase any changes you've made to the layout. But sometimes it is worth it!
I'm using Visual Studio 2008 and I have just noticed that the debugger is displaying integer values as Hex when I hover over variables and also in the immediate window. I guess I must have hit a shortcut key accidently or something.
Anyone had this before? How do I set it back to display in decimal?
Right-click your Watch Window or Immediate Window and uncheck Hexadecimal Display option.
You can also choose hexadecimal or decimal display on a per-variable basis in the Visual Studio watch window by appending a debugger format specifier to the variable name. In the watch window, enter:
myInt,h
myInt,d
The other very useful format specifiers are ac (see footnote) for 'always calculate', and nq for displaying with 'no quotes.' They can be used together:
my_string_func(),ac,nq
nq is useful inside DebuggerDisplay attributes, which can appear on a class:
[DebuggerDisplay("{my_string_func(),nq}")]
class MyClass
{
/* ...example continues below... */
...or on one or more field(s) inside a class:
[DebuggerDisplay("{some_field,nq}", Name="substitute name here")]
int an_integer;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
String some_field;
}
http://msdn.microsoft.com/en-us/library/e514eeby(v=VS.100).aspx
note that earlier versions of the MSDN doc page incorrectly said 'Ac' (with a capital 'A')--which doesn't work
There is a Hex button shown when Visual Studio is run in Debug mode to enable/disable the Hex display
Right-click on client space of almost every debug window (except Immediate Window) - watch/locals/autos/threads/call stack - and uncheck "Hexadecimal Display" option.
There's also a "Hex" button in debug toolbar (right to "Step Over" by default) when debugging.
In Visual Studio 2010 I also saw it in the Debug toolbar, it was highlighted in yellow 'Hex', I just clicked it and it returned to (normal) decimal values
Visual Studio 2017
Decimal vs. hexadecimal display is controlled only from the Watch dialog.
Break after setting the variable.
Right mouse click the variable and select "Add Watch" or "QuickWatch"
Right mouse click the line in the Watch dialogue.
Uncheck "Hexadecimal Display"
The display will now be in decimal.
In the immediate window you can uncheck the Hexadecimal Display option.