Microsoft Visual Studio 2013 Tips and Tricks

Microsoft released Visual Studio 2013 on November 13, 2013. With this new release came many cool features for .net developer’s to take advantage of. I’ve outlined below some of the new features that I’ve found most interesting.

Open the Resolve menu when typing happens once in a while that you haven’t included the namespace you need at the top of your file. One common example is Trace found in System.Diagnostics. If you write Trace, Visual Studio suggests TraceMode and other things, but no Trace. To quickly solve this, type Trace followed by CTRL + SPACE + . and the Resolve menu comes up where you can select to include using System.Diagnostics; to make Trace available.

Create a new Azure website from within VS there is no need  to open the Azure portal and create a website there before you publish it using Visual Studio. Now you can do it directly within. You need to make sure you’ve installed Azure SDK 2.2 and can connect to Azure properly.

Live debugging in Azure After you’ve published your website you can also, using live debugging, step through the executed code line by line as if it was on your local machine. Locate your published website under Server Explorer -> Windows Azure -> Web Sites. Right-click on your website and select Attach Debugger.

Live tracing from Azure in the same way you can do live debugging you can also make all trace messages, written in an Azure application, end up in your Visual Studio’s Output window.

Add trace messages to your code simply by writing like this.

Ex. Trace.WriteLine(“This is my trace message”).Don’t forget to re-publish your application if you make any changes to your code.

Locate your website under Server Explorer as you did in the previous step. Right click on it and select View settings. Change Application logging (File system) to Verbose and click Save as done in the picture. Right click on the website again and this time select View streaming logs in Output window. In the Output window you can then see all the trace messages as they are being processed. Don’t forget to turn off Verbose debugging after having done your testing. You might end up with huge amounts of log files otherwise.

64 bit Edit and Continue have we been waiting for this one. Finally, by using .Net Framework 4.5.1, we can have the same edit and continue for 64 bits as we’ve been able to with 32 bit code for ages.

Return value inspection to help out the debugging process you can now easily see return values of functions being used as parameters in other function calls, for example if you nest several functions in each other. 

public partial class MainWindow : Window
{
Random rnd = new Random();
public MainWindow()
{
InitializeComponent();
Foo(Bar() * Bar());
}

int Bar()
{
return rnd.Next(1,100);
}
void Foo(int p)
{
Console.WriteLine(p.ToString());
}
}

After you’ve stepped over line 7 (the call to Foo) this is what you’ll see in the Autos window. We called Bar twice inside the calling to Foo and the results can be seen here.

Just my code this feature tells the debugger to only step through the code you’ve been writing yourself and ignore frameworks and other code. The system is doing this by looking at open projects, .pbd files. For .Net Framework, this came before VS 2013, but what’s new now is that it’s available for C++ and JavaScript as well. To enable or disable Just My Code, open Debug -> Options and Settings -> General and change the value of Enable Just My Code.

Peek a definition It’s now possible to open up a method definition without having to open that specific file. You can even open up a section located further up/down in your current file without having to leave the location you are at now. This feature is called Peek Definition and can be accessed through ALT + F12 or by right clicking the method and select Peek Definition. Here is an example where I’m peeking on the InitializeComponent() method.

All of these cool features will help developers code faster and more effectively.


There are many more new features like the new .Net framework 4.5.1, and visual studio online. Which are your favorite ones? Let us know in the comments below.

Leo Baker

Leo Baker

Leonard Baker is a .Net/Android Developer worked as a Java Developer for a financial institution in Boston. As .Net developer he's worked for government, insurance and financial institutions. Over the past year he has worked on android apps and is excited about future android mobile development.

Leonard is married with two kids and lives in Jacksonville, FL. He loves to travel spend time with his kids, fish and scuba dive.

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories

Search

Recent Posts

Most Common Tags