Exception handling is a vital part of software development. When an exception occurs at runtime, due to any error in the code, we handle those with a try {} catch {} block. The try {} block contains the code where the exception occurred; the catch {} block knows how to handle that, based on the type of the exception. After the exception has been handled, the normal execution of the program continues without affecting the application.
Though, in most of the cases we handle, there could be cases that may go unnoticed and come into the picture at runtime. Such an unhandled exception crashes the application. In this recipe, we will learn how to catch the unhandled exceptions in the WPF application and close the application properly.