Welcome to MSDN Blogs Sign in | Join | Help

Sara Ford's WebLog


My adventures embracing open source on CodePlex and at Microsoft

News

  • Did you know... All author proceeds go directly to sending Hurricane Katrina survivors to college.

    This is just a test. don't look here.

    Recent Entries

Did you know… You can double-click on the properties folder in the Solution Explorer to open the project properties page - #368

This was a user-submitted tip from back in May 2008. I really do read all incoming email, but it just takes me a while to respond.

And yet again, I didn’t know about this functionality. I find these little things about the IDE fascinating, because there’s only 5 other ways to open the project properties. But this one wins the award for being the most hidden! =D

Double-click the properties folder in Solution Explorer (whether it is expanded or collapsed) to open the project properties page.

properties folder in solution explorer

Technorati Tags: ,
  (I’m guessing this works in 2005. If not, please let me know.)
Did you know… There’s is a Go To Definition navigation stack?! - #367

I added the exclamation point, because I never knew this. It is amazing that I’m still finding out about IDE features! When does the madness end? But in all fairness, this is a specific C# IDE feature, as it relates to the Go To Definition Window. (Sorry VB folks to do this to you yet again. And to the C/C++ folks, see my note below.)

We know that Visual Studio has a navigation stack because of the Navigate Forward and Navigate Backward keyboard shortcuts. But apparently, and little did I know, that Visual Studio has a separate navigation stack to track cursor movement for Go To Definition calls (but only for C# code?)

Start off by doing a Go To Definition, and of course the cursor moves to the definition. Now to get back to where you were before, you can use CTRL+SHIFT+8.

View.PopBrowseContext command 

And to return to the definition, press CTRL+SHIFT+7.

View.ForwardBrowseContext Ctrl+Shift+7

I’ll be honest here and share that it has taken me over 30 minutes to figure out how this navigation stack works. It wasn’t until I took the screenshot for the Ctrl+Shift+8 keyboard shortcut and realized the command name was “View.PopBrowseContext” that I began to understand what is going on.

Ctrl+Shift+7 will push definitions onto the stack and Ctrl+Shift+8 will pop them off. What was hard for me to get is that this navigation stack is really a “stack,” meaning that push=Go To Definition and pop=go to location the Go To Definition was called. In other words, if you do as many Ctrl+Shift+7 as possible until you run out of definitions (implying an empty stack) and then do a Ctrl+Shift+8 to do a Go To Definition, the stack will have only one definition on it. So your next Ctrl+Shift+7 will only have one place to visit.

For the C/C++ people, it looks like Ctrl+Shift+7 doesn’t work(?) so nothing is ever pushed back onto the stack, so it feels like Ctrl+Shift+8 will only work once.

Hopefully this makes sense!  =D

Please correct me if I’m wrong but I think this is just a VS2008 feature.

Technorati Tags:
Did you know… There’s a way to have Visual Studio log its activity for troubleshooting? - #366

There’s a built-in command line switch devenv.exe /log to log Visual Studio activity, e.g. which packages got loaded, etc. I’ll call out immediately that the documentation is wrong, but you should read Paul’s comments at the bottom of the page for the real documentation (Paul was a dev on VS). http://msdn.microsoft.com/en-us/library/ms241272.aspx

command line devenv /log

If no file is specified, the log is written to

%APPDATA%\Microsoft\VisualStudio\9.0\ActivityLog.xml

And yes, since it is Happy Turkey Day once again, here’s my picture from last time, tip #089 to be exact.

Happy Turkey Day!

Technorati Tags: ,
Did you know… How to add a Linked Item to a project - #365

This feature is helpful when you need a common file shared among projects, like a bitmap, readme, set of common tools and utilities, etc.

To add, right-click on the project in the solution explorer, and select Add – Existing Item.  You’ll notice the “Add” button is one of those button-dropdowns.  Drop down the Add button and select Add a link

Add Existing Item with Add as Link selected

Now you have a linked item in your project as indicated by the shortcut icon.

Linked item in Solution Explorer

The location of the linked file is saved in the project file.  The location must be via the file system, either on different drives or UNC.  No http or ftp.

Technorati Tags: ,
Did you know… Visual Studio comes with an image library for you to use in your applications? - #364

Starting in Visual Studio 2005, you’ll find the Visual Studio Image Library, a zip file that contains over a 1000 images to create applications that have a consistent UI look and feel to Windows, Office, and Visual Studio.

During the Visual Studio setup, the VS2008ImageLibrary.zip file is installed at \Program Files\Microsoft Visual Studio 9.0\Common7\VS2008ImageLibrary\

Visual Studio Image Library

In addition, there’s a set of folders which contain “cut sheets” or basic elements in various sizes that can be used to construct new images using any image editor that utilizes “layers”, such as Paint.NET, Photoshop or Paintshop Pro.  (please don’t ask me about these “cut sheets”, as I’m just relying the message.)

There’s a restriction on the use of the images or common elements that they must be used consistently with the definitions that are found in the readme in each folder. For example, the Visual Studio Class icon must always be used to depict the programming construct of class, and not to represent an unrelated command like “Build Project.”

Technorati Tags: ,
Did you know… You can customize how search results are displayed in the Find Results window? - #363

Argh! I wish I had found this one in time for the book. A second edition, maybe? I’d hate to be known as a one-hit wonder. I’m sure there are more people who could use scholarship money.

Ever did a Find in Files and was annoyed that Visual Studio showed the entire file path, forcing you to scroll over just to see the name of the file and the search result?

Find Results 1 before registry change

Here’s what you can do, among some other tweaks. Note: These involve modifying registry settings. Please use at your own risk! Also Note:  You don’t have to restart Visual Studio to pick up on your registry changes. Sweet!!!

  1. Go to HKCU\Software\Microsoft\VisualStudio\9.0\Find
  2. Add a new string called Find result format with a value of $f$e($l,$c):$t\r\n where

$f is the filename

$e is the extension

$l is the line

$c is the column

$t is the text on the line

Now let’s take a look at that Find Results window again:

Find Results 1 after registry change

And here’s the full list of items you can specify in the registry

Files

$p      path                       

$f      filename               

$v      drive/unc share            

$d      dir                        

$n      name                       

$e      .ext                       

Location

$l      line                       

$c      col                        

$x      end col if on first line, else end of first line

$L      span end line

$C      span end col

Text

$0      matched text               

$t      text of first line

$s      summary of hit

$T      text of spanned lines

Char

\n      newline                   

\s      space                     

\t      tab                       

\\      slash                    

\$      $                         

If you come up with a great combination of values, please leave a comment and share with the group!

Did you know… Dock your Call Stack window alongside the Solution Explorer for a better debugging experience - #362

Whenever I found a bug that required the developer to investigate on my machine, I swear the first thing each and every one of them would do was dock the Call Stack alongside the Solution Explorer.

Call Stack docked alongside Solution Explorer

If you’re dealing with call stacks only 5 lines deep, you’ll probably like the default layout – docked to the bottom.  However, if you’re dealing with call stacks 20 lines deep, you probably want to be able to see more lines without wasting your editor space.  By tab-docking the Call Stack Window alongside the Solution Explorer, you’ll be able to see many more lines in your Call Stack window without rearranging your editor.

Technorati Tags: ,
Did you know… Ctrl+K, Ctrl+v allows you to quickly search for objects within your solution? - #361

Another good keyboard shortcut many don’t know about. I only say that because I forgot all about this one until now…

There is a command called View.ClassViewGoToSearchCombo which does exactly as it says.

image

When you press Ctrl+K, Ctrl+V, wherever you are in the IDE, your focus will jump to the Class View search combo box, so you can just start typing and searching immediately.

Class View with focus on Search Combo Box

Technorati Tags: ,
Did you know… You can use devenv.exe /edit to open a file in an existing Visual Studio instance - #360

Visual Studio has a command line argument you can specify to open a file in an existing instance of VS.

command line example

Just run devenv /edit <filename> and the file will open in the IDE.

file opened in Visual Studio alongside other files

You could also create a VSEdit command if you find yourself using this feature a lot.  Just create a file called "VSEdit.cmd" (you can use notepad to do this) with the following:

@"devenv.exe" /edit %*

provided you already have %Program Files%\Microsoft Visual Studio 9.0\Common7\IDE added to your system PATH environment variable. And, of course, you might want to place this VSEdit.cmd in a directory that's in your PATH or add it.

another command line example

Technorati Tags: ,
Did you know… Ctrl+. shows a smart tag - #359

We’ve all seen smart tags before, the little line that appears whether we’re renaming something or VS wants to help us add a using statement to our code.

C# smart tag example

There are two keyboard shortcuts to invoke (show) smart tags in the editor. There’s the keyboard shortcut no one can seem to remember Alt+Shift+F10, required for consistency with Office’s smart tags. Then there’s the slightly easier to remember keyboard shortcut Ctrl+. (period)

In C# it’s cool that you can just press Ctrl+. then press Enter, and the smart tag does its job. But in VB, you have to press Ctrl+. then arrow down (to select the first item) then press Enter. Sigh, yet another accessibility bug…

VB smart tag example

The command is View.ShowSmartTag if you want to rebind to something else. the Blogosphere seems to like Alt+Down Arrow, which isn’t bound to anything in the Editor scope.

View.ShowSmartTag command

Technorati Tags: ,
Did you know… you can display a license in the Content Installer - #358

Directly from the help documentation:

To display an End User License Agreement (EULA) in the Visual Studio Content Installer, you must embed this information in the .zip file. WinZip supports including embedded information through the Comment feature. For more information about WinZip, see http://www.winzip.com. For more information about the Comment feature, see the WinZip Help file.

Using WinZip 12.0, the Comment feature is found under View – Comment.

As soon as you run a .vsi that has this content embedded in it, you''ll see the EULA dialog box pop up.

Football is spelled s-o-c-c-e-r

Hey, i’m just saying…

Technorati Tags: ,
Did you know… You can view the contents of a .vsi before installing via the Content Installer - #357

On the front page of the Content Installer is a link to view the content in Windows Explorer.

image

When you click the link, Windows Explorer will open up to the temporary location where that .vsi has been unzipped to (or if a .vscontent file, it will explorer that folder wherever it is on disk.)

Windows Explorer on a .vsi file

Technorati Tags: ,
Did you know… You can specify where to install a snippet in the Content Installer - #356

Continuing with yesterday’s tip, whenever you install a code snippet, the content installer will present you with a page (per snippet language) asking you where do you want to install the code snippet.

Content Installer Code Snippet page

and upon completion, you’ll have another chance to review where that snippet got installed to.

Code Snippet Install Successful

Technorati Tags: ,
Did you know… Visual Studio has a Content Installer? - #355

Throughout my blog and my book, I talk passionately about how I loved to test a certain feature or how a certain feature drove me crazy. But no feature has more emotion behind it than the Content Installer. If you ever meet me in person, just say, “Hey Sara, so what’s the deal with that Content Installer?” and let the games begin.

Introduced in Visual Studio 2005, the Content Installer is a wizard that installs various content for Visual Studio, including macros, add-ins, toolbox controls, code snippets, and templates. I can’t recall if help content ever got added. Maybe it did for 2008, but I’m not sure.

Visual Studio content is packaged in a glorified .zip file renamed to “.vsi” (Visual Studio Installer) with the following icon:

a .vsi file icon

When double-clicked, it launches the Visual Studio Content Installer.

Visual Studio Content Installer

Within a .vsi file you’ll find

  1. a .vscontent file
  2. content files (i.e. myaddin.dll, myaddin.addin, mysnippet.snippet, etc.)

Chetan, a fellow SDET back in the day, has a great write-up of how to create .vsi and .vscontent files. Note that you’ll need to ContentVersion to 2.0 for Visual Studio 2008. Another good reference is the VS Content Installer Scheme Reference (note the link is for VS 2005, as the VS 2008 content is seriously lacking in the documentation.)

Upon completion of the wizard, you’ll get confirmation for each piece of content.

content installed successfully

Technorati Tags: ,
Did you know… You can press Ctrl+\, D to view the Code Definition Window – #354

Now before I get the angry emails on my first day back from vacation, I will say up front that there is no love for VB in today’s tip. This is just for C#. As a VB developer from my SDET days, I feel your pain and encourage you to vote for this functionality in VB on the Connect site. If someone finds an open bug, let me know and I’ll post it here.

In the General Development Settings, the keyboard shortcut for the Code Definition Window is Ctrl+\, D. The command is View.CodeDefinitionWindow, in case your keyboard bindings differ.

Code Definition Window

Instead of doing an Edit.GoToDefinition, the Code Definition Window does it for you. Whenever you are on an object, the Code Definition Window will automatically update to show the definition. Kinda cool, huh? (even though the VB developers are grinding their teeth right now.)

Technorati Tags: ,
More Posts Next page »
Page view tracker