Visual Studio 2022’s Debug mode Watch feature to narrow down exception to a more specific exception-type class as opposed to the general C# Exception


Related Posting: Finding specific Exceptions using Visual Studio

Here is info about our technical development environment :

• Microsoft Visual Studio 2022

• .NET 6.0

• C# 10

In a big application, I have a try/catch block that will catch all C# Exceptions at the Program.cs/Main.cs top-level code file.
However, I would like to use Visual Studio 2022’s Debug mode’s “Add Watch” feature that will keep watch of “ex” variable that is of type C# Exception.

Using Visual Studio 2022’s Debug mode’s “Watch” feature , I placed a Watch on the Exception’s ex variable that is in my Program.cs/Main.cs top-level code file. This is shown in the snapshot picture image of the Visual Studio 2022’s Watch window that I copy and pasted below in this posting.

Isn’t there a way to use the Visual Studio 2022’s Debug mode’s “Watch” feature to narrow it down? In other words, isn’t there a way to go down the Exception “ex” variable tree hierarchy shown in the “Watch” window in order to determine the “narrowed down” specific exception type? could someone please tell me how I can narrow down the exception to a more specific exception-type class than the more general C# Exception that is the top ancestor class in the C# Exception classes inheritance hierarchy?

enter image description here

Leave a Reply

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