Visual Studio 2017 – Reattach to Process

I have been in situations number of times that required troubleshooting certain issues against a running process using “Attach to Process” mechanism. The whole process of bringing up “Attach to Process” dialog, finding the right process and then attaching to it etc. could become little tedious process especially when you have to attach, detach and then re-attach against same process multiple times. There was enough need for a better mechanism that there are Visual Studio extensions available for it in the marketplace. Visual Studio 2017 has introduced a new “Reattach to process” option that makes this process little easier.

Let’s say, I need to debug against running instance of IISExpress. I’ll first bring up the Debug -> Attach to Process menu option

1

We can then find the process from this dialog and then Attach to for debugging.
2
Once the troubleshooting is done, we can just Stop Debugging this.

3
So far so good. However, if I need to go back and attach to same process again and again, I needed to repeat all the above steps again & again too. However, if you are using Visual Studio 2017, you should be able to see the following “Reattach to Process” option that will start debugging same IISExpress process again without doing all those steps.

4

Until next, happy debugging!!

Advertisements
Posted in Debugging, CodeProject, Visual Studio 2017 | Leave a comment

Visual Studio 2017 – Process Filter option in Attach to Process dialog

Sometimes there are usability features in the UI that seemingly look small but can have bigger impact on the user experience. In my view, one of the usability feature missing in Visual Studio UI for quite some time was about “Attach to Process” dialog. Below is how this dialog looks in Visual Studio 2015.

1

Attache to a running process is a great feature that I have used on number of occasions. Almost every time I felt that looking for a specific process from this grid was “slow” process as it requires you to scroll through the list.  Guess what, look what we got in Visual Studio 2017.

2

We have an option for filtering by process name. So if I need to look for all the w3wp process, I just start typing the process name and that’s bring up what I was looking for.

3

Until next, happy debugging.

Posted in CodeProject, Visual Studio 2017 | Leave a comment

Productivity Power Tools for VS 2017

Productivity Power Tools is nothing new, many developers are well aware of it and use it for long time. I am certainly among one of them. However, every now and then I come across seasoned developers on Microsoft platform with years of Visual Studio experience who are doing things in old-fashioned way while more efficient mechanisms available such as  Productivity Tools.

With Visual Studio 2017, the tradition for these Productivity Power Tools continue. You can download and download and install it from within Visual Studio 2017. In case you haven’t done it before, simply go the “Extensions and Updates” menu options under Tools as shown below.

1

At this point, simply search for Productivity Power Tools 2017. Once you find it, simply download and install it.2

A full list of available tasks with these tools is available at its page at Visual Studio marketplace as well as its github page.

Being a keyboard junkie, my personal favourite from Productivity Power Tools is QuickTasks which provides quick access to common tasks via the Quick Launch bar. Just as a reminder, you can find the Quick Launch Bar at the top right corner of Visual Stuio as shown below.

3

These quick tasks are available by @tasks shortcut.

4

Below is some tasks that could be performed.

5

A full list of QuickTasks is available here.

Until next, happy debugging.

Posted in Visual Studio 2017 | Leave a comment

Creating Process Dump file from Visual Studio

Dump file based troubleshooting and debugging approaches provide effective ways of understanding certain type of issues. I have written tutorial on this subject to little advanced techniques. When it comes to collecting dump file for a process, I am big fan of tools such as ProcDump and DebugDiag.

I think not many people realize that a process dump file can also be collected from Visual Studio. If you are working from developer’s favourite tool “Visual Studio”, its entirely possible to collect dump file of a target process during debugging without leaving the comfort of Visual Studio. This can be achieved when you are debugging a program. At that point, a menu option of “Save Dump As” becomes available under Debug menu option as shown below.

If user chooses this option, user is prompted to choose the name and location of that dump file as shown below.

Until next, happy debugging!!

Posted in Debugging | Leave a comment

Visual Studio 2017 – Exception Helper (III)

Exception Settings has been a powerful feature in Visual Studio for quite some time now. It has got some extra fire-power with new Exception Helper dialog in Visual Studio 2017. Let’s say, your code is using a third party library that is throwing an exception.Let’s also say  that this exception is of no much interest to you when its raised by that third party library. Otherwise you would like your debugger to break every time that same exception is thrown. Let me show how you can accomplish this with Visual Studio 2017.

Let’s say your solution has a dependency on a third party library for Video Streaming.

0

When using this library, its throwing an exception that’s interfering your debugging experience. In general, you would like your debugger to break on the exception, however, you don’t want the same behaviour when exception is thrown from this VideoStreaming library. With Visual Studio 2017, you can set a condition for this Exception to break except when its thrown from VideoStreaming.dll as shown in the image below.

1

If this check-box for VideoStreaming.dll is checked, it will add a condition in the Exception Settings for this particular type of exception as shown below.

2

In case you decide to remove this setting, just right click on this condition will bring up follow context-menu.

3

Select “Edit Conditions” here, which will bring following pop-up. This dialog provides you ability to either modify the condition or remove it entirely.

4

Until next, happy debugging.

Posted in CodeProject, Visual Studio 2017 | Leave a comment

Visual Studio 2017 – Exception Helper (II)

Another time saving feature in the new Exception Helper dialog in Visual Studio 2017 is about Inner exceptions. In order to elaborate this, let me first introduce you to what happens when an unhandled exception is encountered when debugging code within Visual Studio 2015 (or earlier version). You basically are presented with a dialog showing the type of exception but without why the exception was thrown as shown in image below.
1

Of course, there is a link for View Detail that can help you getting more details about that exception. However, some times the actual exception is buried deep inside nested Inner Exception as in the example shown below.

2

The same scenario in Visual Studio 2017 Exception Helper dialog is presented in following manner. Here you can see that there are three inner exception with the inner most one shown at first.

3

Of course, you can inspect the other two exceptions in this case by left and right navigation arrows as shown in images below.

4

5

Until next, happy debugging!!

Posted in CodeProject, Visual Studio 2017 | Leave a comment

Visual Studio 2017 – Exception Helper

Exceptions is an ancient programming concept that every developer has to deal with in the programs they write during development, testing and production scenarios. Visual Studio has long provided facilities to inspect the exceptions but with Visual Studio 2017, its Exception Helper dialog makes that process even easier.

In order to set the stage, let’s look at the following piece of code, specially the line shown in red rectangle below.

1

As you can see, there are various properties invoked for different objects on this line without ensuring that these objects are not null. This type of code can cause tricky situations to deal with specially in a production environment as I described in one of my article for Visual Studio Magazine.

Let’s say, when debugging this application in Visual Studio 2015, an exception is thrown on the same line of code. In this case, Visual Studio 2015 will display following dialog.

2

Its showing that a NullReferenceException has been caused on the same line but without much details about which object is responsible for the exception. Clicking on View Detail here brings up following dialog.

3

This dialog is also not telling us either about the object causing the exception. Obviously if you are debugging this code, you can inspect all related objects to determine the culprit but this is exactly where Visual Studio 2017 Exception Helper can save some of that time.

Same program when debugged under Visual Studio 2017 presents following dialog.

4.PNG

As you can see in this case, Visual Studio 2017 is clearly showing that its the product.Detail object that returning a null causing the exception. Isn’t it great and a time saver?

There are many other tit-bits that you can do with this Exception Helper in Visual Studio 2017 that I will continue to explore in my upcoming blog posts.

Until next, happy debugging!!

Posted in CodeProject, Visual Studio 2017 | Leave a comment