The opinions expressed in these materials are my own and are not necessarily those of Microsoft.
Copyright © Microsoft Corporation. All rights reserved. Unless otherwise indicated, all source code provided is licensed under the Microsoft Public License (Ms-PL).
Menu: Tools -> Options -> Debugging -> GeneralVersions: 2008,2010Published: 10/25/2010Code: vstipDebug0032
Ever notice the "Enable Just My Code" option in Tools -> Options -> Debugging -> General?
Lots of people wonder what "Just My Code" really means. I thought it would be a good idea to explore this in a little more detail. So let's start with what the documentation says (http://msdn.microsoft.com/en-us/library/h5e30exc.aspx):
"To distinguish user code from non-user code, Just My Code looks at three things: DBG Files, PDB files, and optimization."
DBG and PDB files
One way to figure out what is "your code" is to look and see if it has DBG and/or PDB files. In case you didn't know, DBG files have been superseded by the PDB format. The PDB extension stands for "program database." It holds the debugging information that was introduced in Visual C++ version 1.0. You can find out more about PDB files here: http://support.microsoft.com/kb/121366/en-us. This is typically deep level information about the source so if you have these files either it's your code or someone trusted you enough to give them to you.
When optimization is turned off (the default setting for Debug builds) then that factors into the code being considered "yours". According to the documentation, the optimization "option enables or disables optimizations performed by the compiler to make your output file smaller, faster, and more efficient". There are a ton of optimizations that you can do such as optimizing for application speed or size of your program. You can get a sense of the full list of features here: http://msdn.microsoft.com/en-us/library/k1ack8f1.aspx. Basically, it does a lot of cool things that are great for a shipping application but not for one that you are currently working on.
In C# this is found in the Project properties on the Build tab:
In VB, it is also in the Project properties on the Compile tab but you have to click the "Advanced Compile Options" button:
So if the PDB information is there and optimization is NOT turned on then the code is considered "yours" as far as Visual Studio is concerned. And now you know what "Just My Code" means when you are debugging.
Menu: [Right-Click the Breakpoint] -> ConditionVersions: 2008,2010Published: 5/3/2010Code: vstipDebug0021
Did you know you can set Conditional Breakpoints? They are arguably the most powerful among the types of Breakpoints you can set. There are many layers to using them correctly and knowing is half the battle.
Let's start with the Breakpoint Condition dialog. Notice that the condition can be turned off by unchecking the Condition checkbox. Additionally, there are two options for the condition that you set:
"Is true" is used for Boolean expressions that evaluate to true or false.
"Has changed" means what it says - if the expression changes then the code stops.
Suppose I have this "for" loop:
I can set a simple "Is true" condition that says when the variable "i" is greater than, say, 5 the code should stop:
When I run the code and the Breakpoint is hit, sure enough, it stops when the value of "i" is greater than 5:
This one is more interesting. Basically you set up something to watch. In this case, I'll just have it watch the "i" variable:
When the Breakpoint is hit and the value of "i" has changed in in any way then the code stops:
Anytime you set an advanced Breakpoint you will get a new glyph:
You can always tell what kind of breakpoint you have by looking placing your mouse over the glyph and looking at the tooltip:
Or checking out the Breakpoints window:
This series is based on my IntelliTrace Workshop materials found here: http://sdrv.ms/UPUEE3
This is a multi-part series, you can find the other parts here:
Understanding IntelliTrace Part I: What the @#$% is IntelliTrace?
Understanding IntelliTrace Part II: Where Do I Use IntelliTrace?
Understanding IntelliTrace Part III: IntelliTrace Events
Understanding IntelliTrace Part IV: IntelliTrace Calls
Over the next few posts I’m going to explain IntelliTrace in consumable chunks so folks can get a handle on it. Even though we introduced it in Visual Studio 2010, it’s still one of the more misunderstood features we have in the IDE. Together we will navigate through the what, where, and how of IntelliTrace to, hopefully, come out ready to engage in debugging bliss. :)
Before you can use IntelliTrace you have to understand what it is. There are several good explanations people use to describe how this works. I think the best way to do this is to compare it with live debugging by using an analogy.
NOTE: IntelliTrace can be used for debugging .NET 2.0 - .NET 4.5 assemblies however, you need .NET 3.5 to run IntelliTrace itself so, at a minimum, you need .NET 3.5 and the Framework version you want to debug.
Imagine live debugging as being like directing a cast of people on stage. You can bring different people to the front, you can make them move around, change their look if you want, and so forth. Essentially, you have complete control over what is seen at any point in time BUT you can’t rewind to look at what has happened in the past and you can’t fast-forward. All you can basically do is focus on what is happening right now.
Similarly, you can break execution, step through your code,and even dynamically change variable values for variables in scope. There is a LOT of control but you can’t go back once you have passed a line of code unless you restart the entire debugging session. Therefore, live debugging is very much point-in-time oriented.
Unlike live debugging, IntelliTrace debugging is like watching a video of the stage play. You can fast-forward past the boring parts and rewind if you missed something. The one thing you can’t do is change what is happening since it has already happened in the past. You give up controlling the actors in favor of controlling the timeline. In fact, IntelliTrace was originally called “Historical Debugging” when we introduced it.
I like the title of this section because most people who don’t know about IntelliTrace assume that it replaces live debugging. Let me be perfectly clear: IntelliTrace DOES NOT replace live debugging. Not today, not tomorrow, not ever. In fact, the two were meant to work together. You can see this when you are using IntelliTrace as it always gives you the option to go back to live debugging whenever you want:
It’s common to be in the middle of a live debugging session, then need to use IntelliTrace to see something that happened in the past, and then switch back to live debugging to pick up where you left off.
Okay so I “might” have mislead you into thinking that you would come away from this article completely understanding IntelliTrace but it was all part of my evil plan. You can’t really understand the feature until you use it and that is exactly what we will do in this series. We are going to build up scenarios and and hopefully have you come away with much deeper appreciation of this technology.
Keyboard: CTRL + SHIFT + V; CTRL + SHIFT + INSERTMenu: Edit -> Cycle Clipboard RingCommand: Edit.CycleClipboardRingVersions: 2008,2010Published: 1/2/2010Code: vstipEdit0001
The Clipboard Ring keeps track of the past 20 items you've either cut or copied so you can reuse them over and over again! After you hit item 20, it'll go back to the first item again. This is why the feature is called a Clipboard Ring.
Give it a try! Copy a few pieces of text into your clipboard then keep pressing CTRL + SHIFT + V to cycle pasting them in the editor. This is one seriously cool time-saving feature.
The new book is entering its final stages before we start work in earnest. After much discussion internally we have finally come up with a potential title for the new book and I wanted to get your thoughts. Let me preface this with the following: We wanted to depart from the “tips and tricks” moniker for the book as we feel it doesn’t adequately portray what the book does (or should do at least). With that said, the current thought on a title is (drum roll, please):
Microsoft Visual Studio Productivity Handbook
I really want your feedback on this one. Does it suck? Do you like it? Tell me your thoughts…
Menu: Tools -> Options -> Projects and Solutions -> GeneralVersions: 2008,2010Published: 7/3/2010Code: vstipTool0045
If you don't want the Output Window to show up every time you do a build, you can easily keep it from happening by going to Tools -> Options -> Projects and Solutions -> General and deselect the "Show Output window when build starts" option:
Of course, you can bring up the Output Window anytime by pressing CTRL + ALT + O.
Menu: Tools -> Options -> Projects and Solutions -> GeneralVersions: 2008,2010Published: 5/16/2010Code: vstipTool0022
By default, the Error List will show when there are build errors:
You can change this behavior by going to Tools -> Options -> Projects and Solutions -> General and deselecting the "Always show Error List if build finishes with errors" checkbox:
This week I thought we would focus on some fun quickies that have been in Visual Studio since at least VS2010. The first one we will look at is simply zooming your text in the editor. The concept is really simple. For example, you may want to go from this:
Being able to zoom in and out is useful if you have trouble seeing or you are doing extreme programming or any situation where making text more readable is necessary. One other thing to keep in mind is that zooming is a per tab activity so zooming in one tab does not set the same zoom level in other tabs. Each tab has it's own zoom level.
You can zoom in and out of text using the wheel on your mouse. Just hold down CTRL+Mouse Wheel and you can instantly zoom in and out of text in the editor.
Most people discover this accidentally. If this annoys you then you can see if there is an update to the Disable Mouse Wheel Zoom extension:
At the time of writing there isn’t a version that works with VS2013 but that could change.
You can go “old school” and use the combo box at the bottom left of the IDE:
If you prefer to use the keyboard, you can always use CTRL+SHIFT+>[Greater Than] and CTRL+SHIFT+<[Less Than].
I'm happy to announce that the New Year marks the beginning of my endeavor to carry on Sara Ford's great work with Visual Studio Tips and Tricks for the Visual Studio product (http://blogs.msdn.com/saraford/archive/tags/Visual+Studio+2008+Tip+of+the+Day/default.aspx). After many discussions between us on how best to move the effort forward we decided that continuing the love with 2010 was a good idea. With Sara's help I have managed to get a good idea of her approach and added elements of my own style to the mix.
Additionally, in conjunction with Scott Cate (http://scottcate.com), I am pleased to say almost all tips will include a video showing the tip in action. Many thanks to Scott for stepping up and doing the past and future videos related to this series.
I haven't decided to crank out the book proposal yet for a new edition and probably won't for a while yet but am thinking the updated version will include versions 2005, 2008, and 2010 as well as (per Sara's suggestion) some new sections on extending Visual Studio with macros and the new extensibility model.
There was some debate over whether to wait until VS2010 launches or begin with the New Year. As you can see, I decided to begin on January 1. This is important for a couple of reasons:
1. The tips published until RTM will be based on Beta 2 and RC builds.
2. It is possible (though unlikely) some of the tips may not be valid in the RTM build when it ships. I will be retesting all tips when VS2010 ships to make sure they work as advertised :)
The plan is to have a tip a day posted on this blog with a few extra items thrown in for good measure. What you will see is a healthy mix of new tips in Visual Studio 2010 and some of the old favorites as well (tested to make sure they still work). To be absolutely clear: These are Visual Studio 2010 Tips and Tricks so what you will see are the details on how to leverage old and new content with our latest product. To get things started, and through the inaugural weekend, let's take a look at the #1 tip from Sara's Tips and Tricks:
How to behold the power of Incremental Search
Tip Code: vstipFind0001
Keyboard Shortcut: CTRL + I
Menu Command: Edit -> Advanced -> Incremental Search
Incremental search is a powerful search to use when you want to keep both your focus and your cursor in the editor when searching in the current document. It is powerful because it allows you to keep typing, meaning the search is driven by keystrokes. And you don't need to interact with any UI.
To conduct an incremental search, follow these steps:
Start typing the text you are searching for. You'll see the cursor jump to the first match, highlighting the current search string:
If you look in the lower-left corner of your screen you will see an indication that you are doing an Incremental Search:
Press Ctrl+I again to jump to the next occurrence of the search string:
Here are all the options you can leverage while in this mode:
Move to the next match in the file
Reverse the direction of the search
Remove a character from the search string
Stop the incremental search
Keyboard: CTRL + K, CTRL + K (toggle bookmark)Menu: Edit -> Bookmarks -> Toggle BookmarkCommand: Edit.ToggleBookmarkVersions: 2008,2010Published: 7/5/2010Code: vstipTool0047
Bookmarks are a pretty cool feature that a lot of people don't seem to know about. Essentially, Bookmarks are a way to mark locations in your code. Unlike tokens ("TODO's"), Bookmarks are not stored with the source code. There are numerous ways to set a Bookmark. The simplest way is to use CTRL + K, CTRL + K to create a single Bookmark:
When you set a Bookmark it will create a glyph in the Margin and create an entry in the Bookmarks Window:
The good news is you don't have to keep the default name that is given for the Bookmark. Just RIGHT CLICK the entry in the window and choose "Rename":
Then put in whatever you want for the name and you are good to go:
You can continue to use this method or the menu to create Bookmarks. Another cool way to create Bookmarks is to use the "Bookmark All" (bottom right) button in the Quick Find dialog (CTRL + F):