global exception handling not working - threads?

tpatketpatke Posts: 10 Bronze 2
edited June 25, 2010 6:52AM in SmartAssembly 5
I am using SmartAssembly v.5. ...trying to anyway. :-)

My smartassembly build is not catching unhandled exceptions. Instead, I am getting the standard "Details, Continue, Quit" dialog. I have never had a problem with SmartAssembly catching exceptions before (version 4). Maybe the issue has something to do with the code running on a thread which is not setup to act as a global error handler? The error is being generated on the main GUI thread in main form's KeyDown event.

If I were to delete a dll from the application directory, I would get an error on startup which does show the SmartAssembly global error handler.

Any ideas?

Thanks in advance,

Toby

Comments

  • Did you customize the SA error report module in any way or are you using on of the default ones?
  • tpatketpatke Posts: 10 Bronze 2
    I did customize the error report module, but have since rolled back to the standard reporting module - same issue.
  • tpatketpatke Posts: 10 Bronze 2
    I have been debugging this a bit and I think the problem is caused because I have two Application.Run commands in my application. The first is used to prompt the user to login. The second is used to run the main application.

    If I bypass the login, SmartAssembly seems to work fine. If I login, I get the error described above.

    Any ideas?

    Cheers,

    Toby
  • tpatketpatke Posts: 10 Bronze 2
    Looks like I can use ShowDialog instead of Application.Run. ...but I would still like to know what is going on there?

    Cheers,

    Toby
  • Paul.MartinPaul.Martin Posts: 83 New member
    Calling Application.Run twice is not really supported by Winforms.

    When the login form closes, the last part of the Application.Run(...) call performs various operations that clear-up the application's context. These contexts include the application's ThreadContext, this means the event handler for unhandled exceptions in the thread is removed, stopping the Unhandled Exception feature for being called.


    The better method if you want to have multiple forms displayed is to do Application.Run on the main form, and possibly set it to be hidden in the constructor.
    Then within the main form's load method show the other form.
  • tpatketpatke Posts: 10 Bronze 2
    Learn something new every day. Thanks!! :-)
Sign In or Register to comment.