global exception handling not working - threads?

.NET obfuscator and automated error reporting

Moderators: Luke Jefferson, Alex.Davies, melvyn.harbour

global exception handling not working - threads?

Postby tpatke » Wed Jun 23, 2010 10:08 pm

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
tpatke
 
Posts: 6
Joined: Wed Jun 23, 2010 9:47 pm

Postby Eaton » Thu Jun 24, 2010 2:17 am

Did you customize the SA error report module in any way or are you using on of the default ones?
Eaton
 
Posts: 16
Joined: Tue May 18, 2010 4:20 am

Postby tpatke » Thu Jun 24, 2010 8:27 am

I did customize the error report module, but have since rolled back to the standard reporting module - same issue.
tpatke
 
Posts: 6
Joined: Wed Jun 23, 2010 9:47 pm

Postby tpatke » Thu Jun 24, 2010 9:24 am

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
tpatke
 
Posts: 6
Joined: Wed Jun 23, 2010 9:47 pm

Postby tpatke » Thu Jun 24, 2010 9:33 am

Looks like I can use ShowDialog instead of Application.Run. ...but I would still like to know what is going on there?

Cheers,

Toby
tpatke
 
Posts: 6
Joined: Wed Jun 23, 2010 9:47 pm

Postby Paul.Martin » Thu Jun 24, 2010 11:23 am

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.
Paul.Martin
 
Posts: 83
Joined: Wed Feb 03, 2010 11:20 am
Location: Cambridgeshire

Postby tpatke » Fri Jun 25, 2010 11:52 am

Learn something new every day. Thanks!! :-)
tpatke
 
Posts: 6
Joined: Wed Jun 23, 2010 9:47 pm


Return to SmartAssembly 5

Who is online

Users browsing this forum: No registered users and 1 guest