Using the New Exception Helper in Visual Studio 2017
Dealing with exceptions is a common developer problem no matter your technology or level of expertise. It can be a frustrating experience figuring out why exceptions are causing problems in your code. When you are debugging an exception in Visual Studio, we want to lessen that frustration by providing you with relevant exception information to help you debug your issue faster. So in Visual Studio 2017 we are introducing the simplified, non-modal, new Exception Helper.
In previous versions of Visual Studio, when you break on an exception, you will see the Exception Assistant (when debugging managed code), or the Exception Dialog (when debugging Native code, or if you disabled the Exception Assistant).
We looked closely at both of these dialogs, listened to your feedback on User Voice and from Send-A-Smile, and decided they needed an overhaul.
Highlights of the New Exception Helper
- Breaking on the Line of Code – No matter if you are managed or native debugging, when you break on an exception the debugger will stop you on the line of code where that exception happens. An exception error icon will appear to the right of that line of code and the non-modal, smaller, less distracting Exception helper will pop down from that icon and stay pinned to that code line.
- Exception Information at a Glance – You will instantly be able to read the exception type and exception message in the Exception Helper, and whether the exception was thrown or unhandled.
- Null Reference Analysis – Starting in VS 2017 , for both managed and native code, when you hit a NullReferenceException or an Access Violation, you will see null analysis information in the Exception Helper. If we cannot determine what is null we will not attempt to show any analysis. When we can detect what is null we will emphasize the culprit in bold text. For C++ Access Violations, this analysis will be present in Visual Studio 2015 as well. Note: Null reference analysis in managed code requires .NET version 4.6.2. Null analysis is currently not supported for Universal Windows Platform (UWP) and any other .NET Core applications. It is only available while debugging code that does not have any Just-In-Time (JIT) code optimizations.
- Configure your Exception Settings – When you break on Exception Thrown you can use the checkbox under Exception Settings in the Exception Helper to disable breaking on that exception type when thrown in the future. You can also specify that you do not want to break on this particular exception thrown in this particular module by checking the box by the module name under “Except when thrown from:” in the Exception Settings. You can apply conditions to your exceptions to only break when thrown from certain modules.
- Inner Exceptions right away – No longer will you have to drill into the exception details to see if there is an inner exception. We show it to you right when you break with the ability to navigate back through multiple inner exceptions.
- Move it where you need it – You can drag the Exception Helper from its pinned view to its floating view if it happens to cover up something you need to look at, or you want to view it while switching code files. You can also use the pin icon to float it, or snap it back to the line of code. If you close the Exception Helper, simply click on the exception error indicator to bring it back up.
- Faster breaking for Unhandled Exceptions – When managed debugging, the debugger will no longer automatically unwind the Call Stack when you break on an unhandled exception. This means that you will break into your code faster because the debugger doesn’t need to walk the Call Stack before breaking.
- Non-Modal – When native debugging, you will no longer need to dismiss an exception dialog to inspect your code. The new Exception Helper is available right inline next to your code.
If you need to turn off the Exception Helper go to Debug/Options, scroll down the list and un-check the box for “Use the Exception Helper”. Then use the report a problem feature of Visual Studio to let us know why the Exception Helper wasn’t working for you.
Download Visual Studio 2017 today, use the new Exception Helper, and send us feedback about the experience. We hope you find this it useful and let us know if you have any questions in the comments section below, using the Send Feedback feature in Visual Studio, or via Twitter.
Sign up to help us improve the Visual Studio Debugger: aka.ms/debuggerfb