Catch All Unhandled Exceptions
Imports System Imports System.Windows.Forms Imports System.IO Public Class MainClass Shared Sub Main() AddHandler Application.ThreadException, AddressOf app_ThreadException Application.OnThreadException(New InvalidDataException("There")) Throw New InvalidDataException("Here") End Sub ' Catch a ThreadException event. Shared Private Sub app_ThreadException(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs) Console.WriteLine("Caught unhandled exception") End Sub End Class
1. | Catch Exception Demo | ||
2. | Try and catch Exception: InvalidCastException |