Red Gate forums :: View topic - global exception handling not working - threads?
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 5
SmartAssembly 5 forum

global exception handling not working - threads?

Search in SmartAssembly 5 forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
tpatke



Joined: 23 Jun 2010
Posts: 6

PostPosted: Wed Jun 23, 2010 10:08 pm    Post subject: global exception handling not working - threads? Reply with quote

I am using SmartAssembly v.5. ...trying to anyway. Smile

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
Back to top
View user's profile Send private message
Eaton



Joined: 18 May 2010
Posts: 16

PostPosted: Thu Jun 24, 2010 2:17 am    Post subject: Reply with quote

Did you customize the SA error report module in any way or are you using on of the default ones?
Back to top
View user's profile Send private message AIM Address
tpatke



Joined: 23 Jun 2010
Posts: 6

PostPosted: Thu Jun 24, 2010 8:27 am    Post subject: Reply with quote

I did customize the error report module, but have since rolled back to the standard reporting module - same issue.
Back to top
View user's profile Send private message
tpatke



Joined: 23 Jun 2010
Posts: 6

PostPosted: Thu Jun 24, 2010 9:24 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
tpatke



Joined: 23 Jun 2010
Posts: 6

PostPosted: Thu Jun 24, 2010 9:33 am    Post subject: Reply with quote

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

Cheers,

Toby
Back to top
View user's profile Send private message
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Thu Jun 24, 2010 11:23 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
tpatke



Joined: 23 Jun 2010
Posts: 6

PostPosted: Fri Jun 25, 2010 11:52 am    Post subject: Reply with quote

Learn something new every day. Thanks!! Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group