I implemented the following global exception catch in my WinForms application:
static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MyMainForm()); } catch (Exception ex) { MessageBox.Show("UNHANDLED EXCEPTION: The program will be terminated. Details follow:\n\n" + getExceptionInfoWithDebuggerOutput(ex), "Global Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } Then down the code, an exception is raised (something as this one -- totally due to my forgetfulness):
public partial class MyPage : UserControl { void func1() { SqlConnectionStringBuilder conStr = null; //... later conStr.DataSource = strServer; //<<--- Where exception is raised } } Now, if I'm debugging my project, I see my Global Exception message box from the global exception handler.
But if I'm not debugging my project and run it as Ctrl+F5, or if I build a Release project, I get the following window instead of the one I coded above:

Any idea how to make my global exception handler do the processing instead?