c# 4.0 - Exceptions not caught in release build (WinForm desktop app, C#, VS 2010) -


i developed desktop application, it's done still contains bugs i'm eliminating.

i use general [try...catch] block wrapped around 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 unhandled exception bubble way stack , @ least responded communicative message box.

it works fine when run application under visual studio (debug mode), when deployed , installed on pc, doesn't - that's when bug (which i've identified, way) causes read null array

alt text

why? baffles me really. why "unhandled"? understanding try...catch should work regardless of whether it's release or debug mode, otherwise point.

this kind of old, if still need solution, need handle events, enclosing entire thing in try catch won't work. this:

    /// <summary>     /// main entry point application.     /// </summary>     [stathread]     static void main()     {         application.enablevisualstyles();         application.setcompatibletextrenderingdefault(false);         appdomain.currentdomain.unhandledexception += processappexception;         application.threadexception += processthrexception;         application.run(new mainform());     }      private static void processappexception(object sender, unhandledexceptioneventargs e)     {         xtrafunctions.logexception((exception)e.exceptionobject);         throw (exception)e.exceptionobject; //messagebox in case.     }      private static void processthrexception(object sender, threadexceptioneventargs e)     {         xtrafunctions.logexception(e.exception);         throw e.exception; //messagebox in case.     } 

when exception isn't caught, go through 1 of before displaying exception dialog. have option override , display nice message of choice.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -