How to view an exception that wasn’t explicitly caught in C#?

So, you decided to do that catch statement without actually declaring the Exception err variable. Sure, code analysis said you weren’t using it. You didn’t want to log it, and you just thought you wanted to swallow the error whole and never see it again. Until…..

Wow, it keeps crashing in the Try block and you have no access to the error when it hits the catch now. What to do? Never fear.

Open your immediate window. Debug->Immediate.
Type $exception then hit enter.
Yep, there is your exception staring at you in all its glory.


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.