开发者

Application crash

I have an application that, as any other app, crashes once in a while for various reasons.

When it crashes, it does it gracefully and the users get a nice message of the crash. At the same time the crash is reported on the server for analysis so it can be fixed in future versions. However, I would like that the app keeps working through the cra开发者_Go百科sh.

What that means is that I would like to run the forms in an 'atomic' way. If it goes down, it doesn't take down the entire app. The users should just need to start over the work done with the particular form.

Is this something that can be done through architecture? Or maybe the new framework versions has something to aid this?

The application is build mostly in C# over the 3.5 framework, but it also uses some external references, some COMs and web service references.

I am not interested in an answer: 'well fix the crashes'. Me and my team and the testing team are working round the clock for this.


Also handling the AppDomain.CurrentDomain.UnhandledException event may help.


Depending on what type of application it is there is an un-handled exception handler in most appliactions.

In a Web Applications the System.Web.HttpApplication has an Error event.

In a Wpf Applications System.Windows.Application has a DispatcherUnhandledException event.

In Windows forms the System.Windows.Forms.Application has a ThreadException event.

You can hook in to these events and handle any exception which is out of your control.


You need to catch the exceptions (assuming that it is exceptions that are being raised) at the most appropriate level.

If you want the application to carry on if the current form raises an exception then you'll need something like the following code:

try
{
    // Show your form
}
catch (YourException ex)
{
    // log the exception
}

If more than one exception can be raised then these should be trapped explicitly - don't trap Exception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜