The top screenshot is ThreadExceptionDialog. It is displayed in the most specific case when the Winforms application is bombed in the event handler that was launched by the message loop (Application.Run), and the application otherwise did not reassign the Application.ThreadException event handler. Using it is not a good practice, there is no reasonable way in which the user could know whether to click the Continue or Exit button. Be sure to call Application.SetUnhandledExceptionMode () to disable it.
The bottom screenshot is the default Windows Error Reporting dialog box displayed by Windows when the program is bombarded with an unhandled exception. You should never allow this to come to this, the dialog box does not display enough information to help someone diagnose and fix the problem. Always write an event handler for the AppDomain.CurrentDomain.UnhandledException event. Display and / or write e.ExceptionObject.ToString () and call Environment.Exit () to terminate the application.
Make your Program.cs source code look like this:
[STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.Run(new Form1()); } static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
source share