Managing unhandled exceptions in Wizard for Win Forms

Wizard for Windows Forms Forum

Posted 11 years ago by Peter McLaren - Senior Software Engineer (DevOps), FIS Systems NZ Ltd
Version: 3.0.0133
Avatar
Hi,

When we write tools and wizard style apps we like to use an exception handling pattern that prevents unhandled exceptions crashing the app with the default .Net message. For a Windows Forms app we put a Try.. Catch ex as Exception in the Main() startup routine, and the catch block calls our own exception handler method which displays a better message and writes to a trace file. To be really sure, we also add handlers for the AppDomain.UnhandledException and Application.ThreadException events. These handlers also call our exception handling method. The ThreadException event is raised when an exception unwinds back to the nearest message pump.

In a standard WinForms app, if an exception that you didn’t anticipate is thrown in a handler such as Button.Click, then the ThreadException event will fire. When our handler has dealt with this, the application will continue.

In an Actipro Wizard winform, an unhandled exception inside a handler like Wizard.SelectionChanging does not cause ThreadException to fire as it unwinds. Instead the original exception seems to be thrown twice. It’s almost like the exception is being squashed by a Try..Catch everything somewhere in the Actipro part of the stack.

One way to work around this is put a Try..Catch in every Actipro handler I implement, but this isn’t very nice. I was wondering what everyone else does about consistent exception handling in their wizards?

We're using Wizard v3.0.0133 for Windows Forms.

Regards
Pete

Comments (4)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Pete,

Good point, it looks like we do have try...catch around the event raising code for SelectionChanging And SelectionChanged but that should be it.

Normally we make an explicit point NOT to put try...catch within our controls so that you can be properly notified of exceptions and handle them in your own way. I did searching and these are the only ones that appear to be this way. We'll remove the try...catch wrappers there for the next maintenance release.


Actipro Software Support

Posted 11 years ago by Peter McLaren - Senior Software Engineer (DevOps), FIS Systems NZ Ltd
Avatar
That's great, thanks. You're right - I debugged some more Actipro event handlers and they raised the ThreadException event ok. In the meantime, I will put extra effort into my own Try..Catch in the SelectionChanging and SelectionChanged handlers.

BTW, the RSS feed button on this forum doesn't seem to be working while others do? I get this error
Internet Explorer cannot display this feed
This feed download was interrupted.

Regards,
Pete
Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Pete, that's odd. The feed shows up in IE ok when I view it in mine. I'm using IE 7.


Actipro Software Support

Posted 11 years ago by Peter McLaren - Senior Software Engineer (DevOps), FIS Systems NZ Ltd
Avatar
Doesn't matter - it might be firewalls or proxies or whatever, but I can spend my time on better things.
Pete.
The latest build of this product (v2018.1 build 0341) was released 9 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.