C# – Global exception event handlers

There are two global exception event available in all .NET applications: FirstChanceException: When any exception is thrown, this event is fired before anything else. UnhandledException: When there’s an unhandled exception, this event is fired right before the process is terminated. You wire up these event handlers in Main() (before anything else has executed), like this: … Read more

C# – Try/finally with no catch block

Try/finally blocks are useful for when you are required to do something at the end of a method no matter what. The finally block always executes, even if there’s an exception (there is one case where this isn’t true, which I’ll explain in the Unhandled exception section below). There are a few common scenarios where … Read more