Set Conditions for Exception in Visual Studio 2017

By | August 14, 2017
In Visual Studio, you can use Exception Settings Window to manage the exceptions – for which exception to break, at which point to break, to add or deleting exceptions. The Exception Settings windows for Visual Studio is there for quite some time. You can open the exception settings window by navigating from Debug -> Windows -> Exception Settings. With Visual Studio 2017, it has some additional features and which is quite useful. You can now set the condition on the exception in the Exception settings Windows. With that, only when there is a matched condition, IDE will throw an exception.

 Navigate to Exception Settings Windows, and select then select the corresponding exception types for which you want to apply the condition. Then choose the  Edit Condition icon from the tool bar
Exception Condition
Inside Edition Conditions window, provide the modules names for only which you want to raise the exception. Currently, it’s only allowed for Modules.
Exception Condition Settings

Exception Condition Settings

Once the condition is applied, you can see the same within your conditions column.

Exception Condition Applied

Exception Condition Applied

With that when the code is running, Visual Studio will only throw CLR exception based on the applied condition.  You can also add multiple conditions, and can only use this for Modules for now – either equal or not equal as condition.

This feature is handy when you want to exclude some of the libraries knows issues ( you may know they are under development ), or some third-party libraries.

Hope this helps.

 

 

One thought on “Set Conditions for Exception in Visual Studio 2017

  1. Pingback: Dew Drop - August 14, 2017 (#2541) - Morning Dew

Leave a Reply

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

Verify Captcha * Time limit is exhausted. Please reload the CAPTCHA.