Tag Archives: Visual Studio

Visual Studio Tips – By Video

I just wanted to share with the world some productivity tips which I use when using Visual Studio 2013. I’ve confined the tips to Visual Studio 2013, which is not running Resharper. The tips are conveyed in this video:

If you have particular thing that you use, please share it in the comments!

The Breakpoint will not Currently Be Hit

There are few things more frustrating than your breakpoints not being hit. In such cases, I’m sure you’ve all seen the following message when hovering over the breakpoint being missed:

The breakpoint will not currently be hit. No symbols have been loaded for this document.

The way that I like to resolve that (which has worked from me more often than not) is to find the pdb file which is actually loading the symbols and deleting it. Usually, that file is stale and by deleting it, you’re forcing the Build to create a new pdb file which will contain your fresh code.

Here are the steps involved.

  1. start debugging a project (press F5)
  2. go to the Debug menu, click the Windows submenu and select Modules (only visible when debugging, hence step 1)
  3. identify the DLL you are interested in and copy the path to the folder containing the symbol file (pdb) into the address bar of Windows Explorer

Then it’s up to you whether you just delete the single file, the folder containing it, or more. As it is a shadow copy, there is no harm in deleting the whole folder. In fact, I usually go several directories above that directory and delete that directory tree:

Bundling Using XML with the Web Essentials Extension

We saw, with the release of MVC 4, the addition of a bundling and minification framework for the optimisation of web resources. This can be configured using the new API (in code). However, I have now stumbled upon an alternative way of implementing bundling using XML files.

Firstly, you need to install the Web Essentials Visual Studio extension (I would use Nuget for that).
If you want to bundle up some JavaScript files, all you need to do is right-click on the files which are to be added to the new bundle and then click on Create JavaScript bundle file from the context menu:
Your solution will now look something like this:
The cool thing is, if you change any of the source JavaScript files, the files in the bundle are automatically updated.
Nice work Mads!

Act Arrange Assert Comment Snippet

When I write unit tests, I like to quickly add the following commenting or scaffolding:

public void NameOfTestMethod()
	//  Arrange

	//  Act

	//  Assert     

As I’m always on the lookout to streamline my workflows, I created a Visual Studio snippet for that commenting. The text of the snippet is:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
 <CodeSnippet Format="1.0.0">
   <Title>Act Arrange Assert</Title>
   <Description>Code snippet for Act, Arrange Assert text.</Description>
   <Code Language="csharp"><![CDATA[//  Arrange

            //  Act

            //  Assert                        

There’s a couple of ways of installing that snippet:

  1. Copy that text into a text editor and save it as a file with the snippet file extension into the relevant directory for snippets in your environment (I called mine aaa.snippet) . For me, that was
    E:\Documents\Dave\Documents\Visual Studio 2013\Code Snippets\Visual C#\My Code Snippets
  2. Open the Code Snippets Manager (Tools > Code Snippets Manager) and import it via that GUI:


To use the snippet, you just type the letters aaa then immediately hit the tab key twice. Also, you will need to restart Visual Studio (if it was already open when you saved the snippet).

Finding a File in Visual Studio – the Quick Way

If you do not have Resharper installed (as I don’t on my work machine), there is a nice little nugget of goodness in Visual Studio to help quickly find a file in a massive solution.

Go to the Find in Files ComboBox, which you will find on the Standard Toolbar:

The syntax is as depicted in the picture above. That is:

>of [name of file]

When you hit Enter, the file which you select will be loaded in the editor.