Set Conditions for Exception in Visual Studio 2017

Set Conditions for Exception in Visual Studio 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.



Subscribe To Newsletter For your Daily Development Tips and Tricks  

 Best Tips & Tricks on Microsoft Technology Platform 

Invalid email address
We promise not to spam you. You can unsubscribe at any time.
Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

One Comment to “Set Conditions for Exception in Visual Studio 2017”

Comments are closed.