Click here to Skip to main content
15,794,240 members
Articles / General Programming / Debugging

Visual Studio 2017 – Exception Helper

Rate me:
Please Sign up or sign in to vote.
4.71/5 (4 votes)
22 May 2017CPOL2 min read 8.8K   1   1
A quick tip on how the new Exception Helper feature in Visual Studio 2017 can make your debugging experience a little quicker.

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 articles 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 the following dialog.

2

It's 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 the 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 the following dialog.

4.PNG

As you can see in this case, Visual Studio 2017 is clearly showing that it's the product.Detail object 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!!

Filed under: CodeProject, Visual Studio 2017
Image 5 Image 6

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Canada Canada
Kamran Bilgrami is a seasoned software developer with background in designing mission critical applications for carrier grade telecom networks. More recently he is involved in design & development of real-time biometric based security solutions. His areas of interest include .NET, software security, mathematical modeling and patterns.

He blogs regularly at http://WindowsDebugging.Wordpress.com

Comments and Discussions

 
QuestionThe Exception Helper is NO help AT ALL!! Pin
frazGJF26-Feb-18 11:45
frazGJF26-Feb-18 11:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.