Click here to Skip to main content
13,143,774 members (32,206 online)
Click here to Skip to main content
Add your own
alternative version

Stats

3.5K views
1 bookmarked
Posted 22 May 2017

Visual Studio 2017 – Exception Helper

, 22 May 2017
Rate this:
Please Sign up or sign in to vote.
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

License

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

Share

About the Author

Kamran Bilgrami
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

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170915.1 | Last Updated 23 May 2017
Article Copyright 2017 by Kamran Bilgrami
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid