views:

14

answers:

0

I developed a desktop application, it's almost done but still contains some bugs which I'm eliminating.

I use a general [try...catch] block wrapped around my application

[STAThread]
static void Main()
{
   try
   {
       program = new Program();
       // ...
   }
   catch (Exception x)
   { 
       // ...
       MessageBox.Show(
          message,
          Resources.MESSAGEBOX_ERROR_CRASH_Caption,
          MessageBoxButtons.OK,
          MessageBoxIcon.Error);
   } 
}

my Program class constructor being:

public Program()
{
    // [...]
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    // [...]
    frmLogon = new Logon();            
    Application.Run(frmLogon);
}        

to ensure that any unhandled exception will bubble all the way up the stack and is at least responded to with some communicative message box.

It works fine when I run the application under Visual Studio (debug mode), but when I deployed it and installed on my PC, it doesn't - that's what I get when the bug (which I've already identified, by the way) causes it to read from a null array

alt text

Why? It baffles me really. Why was it "unhandled"? It was my understanding that try...catch should work regardless of whether it's release or debug mode, otherwise what would be the point.