You can handle the Application.ThreadException event. See the FrameWork class library for a more detailed sample in both VB and C#.
[STAThread]
public static void Main()
{
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(UnhandledExceptionCatcher);
Application.Run(new Form1());
}
private static void UnhandledExceptionCatcher(object sender, System.Threading.ThreadExceptionEventArgs e)
{
Console.WriteLine('caught an unhandled exception.');
}
Share with