Hi,
I've recently ported a .Net 1.1 application to .Net 2.0 and the one new
feature that is getting on my nerves is that when there is an unhandled
exception the application completely crashes, causing user to loose all
the work they have done where they could previously just click continue
and in 99% of cases be fine. Is there an option to turn this annoying
crash and loose everything option off, I can see it has its merits but
in my case its just annoying.
Joe. 20 11088
<jo**************@hotmail.comwrote in message
news:11*********************@s34g2000cwa.googlegro ups.com...
I've recently ported a .Net 1.1 application to .Net 2.0 and the one new
feature that is getting on my nerves is that when there is an unhandled
exception the application completely crashes, causing user to loose all
the work they have done where they could previously just click continue
and in 99% of cases be fine. Is there an option to turn this annoying
crash and loose everything option off, I can see it has its merits but
in my case its just annoying.
Well, the first question I guess is why might there be an unhandled
exception...? Are you not using exception handling i.e.
Try...Catch[...Finally]?
Secondly, why does your Global.asax not have an Application_Error
routine...?
Mark Rae wrote:
<jo**************@hotmail.comwrote in message
news:11*********************@s34g2000cwa.googlegro ups.com...
I've recently ported a .Net 1.1 application to .Net 2.0 and the one new
feature that is getting on my nerves is that when there is an unhandled
exception the application completely crashes, causing user to loose all
the work they have done where they could previously just click continue
and in 99% of cases be fine. Is there an option to turn this annoying
crash and loose everything option off, I can see it has its merits but
in my case its just annoying.
Well, the first question I guess is why might there be an unhandled
exception...? Are you not using exception handling i.e.
Try...Catch[...Finally]?
Secondly, why does your Global.asax not have an Application_Error
routine...?
The main cause of exceptions has been cross thread exceptions on
controls, which I know can be set to be allowed but I do want to root
them all out. Also as a general preference if a new bug finds its way
in I'd prefer the user to at least have the option to try to continue.
It handles the "AppDomain.CurrentDomain.UnhandledException" to log the
problem if thats what you mean, but after this the application still
exits.
All I'm really asking is there a way to avoid the application closing
on an unhandled exception, not how to avoid unhandled exceptions.
<jo**************@hotmail.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
It handles the "AppDomain.CurrentDomain.UnhandledException" to log the
problem if thats what you mean, but after this the application still
exits.
All I'm really asking is there a way to avoid the application closing
on an unhandled exception, not how to avoid unhandled exceptions.
http://www.developer.com/net/asp/article.php/961301
<jo**************@hotmail.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
>
Mark Rae wrote:
><jo**************@hotmail.comwrote in message news:11*********************@s34g2000cwa.googlegr oups.com...
I've recently ported a .Net 1.1 application to .Net 2.0 and the one new
feature that is getting on my nerves is that when there is an unhandled
exception the application completely crashes, causing user to loose all
the work they have done where they could previously just click continue
and in 99% of cases be fine. Is there an option to turn this annoying
crash and loose everything option off, I can see it has its merits but
in my case its just annoying.
Well, the first question I guess is why might there be an unhandled exception...? Are you not using exception handling i.e. Try...Catch[...Finally]?
Secondly, why does your Global.asax not have an Application_Error routine...?
The main cause of exceptions has been cross thread exceptions on
controls, which I know can be set to be allowed but I do want to root
them all out. Also as a general preference if a new bug finds its way
in I'd prefer the user to at least have the option to try to continue.
It handles the "AppDomain.CurrentDomain.UnhandledException" to log the
problem if thats what you mean, but after this the application still
exits.
All I'm really asking is there a way to avoid the application closing
on an unhandled exception, not how to avoid unhandled exceptions.
What do you mean with " cross thread exceptions on controls"? Web controls don't have thread
affinity, why should you ever get this kind of exceptions? Am I missing something?
Willy.
What do you mean with " cross thread exceptions on controls"? Web
controls don't have thread affinity, why should you ever get this
kind of exceptions? Am I missing something?
Unless I blinked, the OP never mentioned web; Mark did (via
Global.asax)
Marc
Mark Rae wrote:
<jo**************@hotmail.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
It handles the "AppDomain.CurrentDomain.UnhandledException" to log the
problem if thats what you mean, but after this the application still
exits.
All I'm really asking is there a way to avoid the application closing
on an unhandled exception, not how to avoid unhandled exceptions.
http://www.developer.com/net/asp/article.php/961301
Its a application, not web application
"Marc Gravell" <ma**********@gmail.comwrote in message
news:ud**************@TK2MSFTNGP04.phx.gbl...
>What do you mean with " cross thread exceptions on controls"? Web controls don't have thread affinity, why should you ever get this kind of exceptions? Am I missing something?
Unless I blinked, the OP never mentioned web; Mark did (via Global.asax)
Apologies for causing any confusion - I quoted the link as an example of
global exception handing - probably should have looked for a WinForms one,
really...
You should handle unhandled exceptions :).
Code in your Program class will be like this:
//Main method:
Application.ThreadException += new
ThreadExceptionEventHandler(OnThreadException);
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new formMDI());
//event handlers
private static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
MessageBox.Show("CurrentDomain_UnhandledException: " +
e.ExceptionObject);
}
private static void OnThreadException(object sender,
ThreadExceptionEventArgs t)
{
MessageBox.Show("OnThreadException: " + t.Exception);
}
Best Regards,
Boban
*** Sent via Developersdex http://www.developersdex.com ***
Boban Stojanovski wrote:
You should handle unhandled exceptions :).
Code in your Program class will be like this:
//Main method:
Application.ThreadException += new
ThreadExceptionEventHandler(OnThreadException);
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new formMDI());
//event handlers
private static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
MessageBox.Show("CurrentDomain_UnhandledException: " +
e.ExceptionObject);
}
private static void OnThreadException(object sender,
ThreadExceptionEventArgs t)
{
MessageBox.Show("OnThreadException: " + t.Exception);
}
Best Regards,
Boban
*** Sent via Developersdex http://www.developersdex.com ***
I have similar code in my app, but after the UnhandledException is
handled, the application still exits, what I need is to be able to
continue running the program like you can in .Net 1.1
Hi,
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
<jo**************@hotmail.comwrote in message
news:11*********************@s34g2000cwa.googlegro ups.com...
>I've recently ported a .Net 1.1 application to .Net 2.0 and the one new feature that is getting on my nerves is that when there is an unhandled exception the application completely crashes, causing user to loose all the work they have done where they could previously just click continue and in 99% of cases be fine.
Well, you have to start handling your errors :) , if you know an operation
may fail wrap it in try/catch
The application will ends when it find an error that was not handled. I
don't see nothing wrong with that.
It's your responsability to either save the work and/or correctly handle the
errors.
--
Ignacio Machin
machin AT laceupsolutions com
Hi,
<jo**************@hotmail.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
>
The main cause of exceptions has been cross thread exceptions on
controls, which I know can be set to be allowed but I do want to root
them all out.
You should then correctly handle that case, you should not try to update the
UI from a worker thread, if you do you may get problems (even if not an
exception) these are the kind of problems that are hard to find/correct.
I'm not asking for advice on how to handle errors, I'm asking if it is
possible to stop .Net 2.0 from exiting the application in exactly the
same way .Net 1.1 does when there is an unhandled exception..
Please dont answer with code suggestions to prevent unhandled
exceptions occuring, its a simple question.
The application will ends when it find an error that was not handled. I
don't see nothing wrong with that.
I see no problem with this been the default, but to make it the only
possible option, especially when it was not the case in previous
versions is annoying and not very backward compatible. I was kinda
hoping there would be a flag like the one for CrossThreadOperations on
controls or a way to stop the application closing in the
OnUnhandledException event.
"Marc Gravell" <ma**********@gmail.comwrote in message
news:ud**************@TK2MSFTNGP04.phx.gbl...
>What do you mean with " cross thread exceptions on controls"? Web controls don't have thread affinity, why should you ever get this kind of exceptions? Am I missing something?
Unless I blinked, the OP never mentioned web; Mark did (via Global.asax)
Marc
Right I see :-(
Willy.
Well, my exception handler doesn't close the application, so you must
be doing something wrong. Are you sure you're attaching a listener to
the System.Windows.Forms.Application.ThreadException event?
A better way to handle this though would be to fix the cause of the
exceptions. jo**************@hotmail.com wrote:
The application will ends when it find an error that was not handled. I
don't see nothing wrong with that.
I see no problem with this been the default, but to make it the only
possible option, especially when it was not the case in previous
versions is annoying and not very backward compatible. I was kinda
hoping there would be a flag like the one for CrossThreadOperations on
controls or a way to stop the application closing in the
OnUnhandledException event.
Well, my exception handler doesn't close the application, so you must
be doing something wrong. Are you sure you're attaching a listener to
the System.Windows.Forms.Application.ThreadException event?
A better way to handle this though would be to fix the cause of the
exceptions.
One final note, there are some exceptions like OutOfMemoryException
that cannot be caught. jo**************@hotmail.com wrote:
The application will ends when it find an error that was not handled. I
don't see nothing wrong with that.
I see no problem with this been the default, but to make it the only
possible option, especially when it was not the case in previous
versions is annoying and not very backward compatible. I was kinda
hoping there would be a flag like the one for CrossThreadOperations on
controls or a way to stop the application closing in the
OnUnhandledException event.
I see no problem with this been the default, but to make it the only
possible option, especially when it was not the case in previous
versions is annoying and not very backward compatible.
The only difference now is that before your apps were working incorrectly
and you didn't realize it, now your app works incorrectly and you do realize.
I would say that trying to be backwards compatible would be the wrong thing
to do, better to let the user know something has gone wrong and lose data
upto a certain point rather than let them continue and possibly lose even
more work.
Mark.
-- http://www.markdawson.org http://themightycoder.spaces.live.com
"jo**************@hotmail.com" wrote:
The application will ends when it find an error that was not handled. I
don't see nothing wrong with that.
I see no problem with this been the default, but to make it the only
possible option, especially when it was not the case in previous
versions is annoying and not very backward compatible. I was kinda
hoping there would be a flag like the one for CrossThreadOperations on
controls or a way to stop the application closing in the
OnUnhandledException event.
You can force the 2.0 runtime to use the same default behavior for unhandled
exceptions as the 1.1 runtime. There's a compatibility flag called
legacyUnhandledExceptionPolicy that you can add to the app.config file,
as...
<legacyUnhandledExceptionPolicy enabled="1"/>This link explains it: http://msdn2.microsoft.com/en-us/lib...65(VS.80).aspx
I suggest only using this flag when using 3rd party libraries that you
cannot get fixed: there's never a good reason to use it for your own code.
<jo**************@hotmail.comwrote in message
news:11*********************@s34g2000cwa.googlegro ups.com...
Hi,
I've recently ported a .Net 1.1 application to .Net 2.0 and the one new
feature that is getting on my nerves is that when there is an unhandled
exception the application completely crashes, causing user to loose all
the work they have done where they could previously just click continue
and in 99% of cases be fine. Is there an option to turn this annoying
crash and loose everything option off, I can see it has its merits but
in my case its just annoying.
Joe.
You can force the 2.0 runtime to use the same default behavior for unhandled
exceptions as the 1.1 runtime. There's a compatibility flag called
legacyUnhandledExceptionPolicy that you can add to the app.config file,
as...
<legacyUnhandledExceptionPolicy enabled="1"/>This link explains it: http://msdn2.microsoft.com/en-us/lib...65(VS.80).aspx
I suggest only using this flag when using 3rd party libraries that you
cannot get fixed: there's never a good reason to use it for your own code.
Thanks, thats exactly what I'm after.
I can see the point about not using this flag out of principle, but at
present I have an app that has a couple of months of new development in
2.0 and will take another couple of months of make bug free in 2.0,
faced with a choice between rolling back 2 months work, repeating and
spending 2 months fixing bugs before getting onto 2.0 and using a flag
to allow me to continue using the newer version while fixing the bugs,
I'm happy using the flag.
Glad it helped, but there's nothing more permanent then a temporary fix. I
personally believe that threading and error handling is so important that I
would stop all other work until those problems were resolved. The more code
that gets piled on top of buggy code the harder it is to fix.
<jo**************@hotmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
>You can force the 2.0 runtime to use the same default behavior for unhandled exceptions as the 1.1 runtime. There's a compatibility flag called legacyUnhandledExceptionPolicy that you can add to the app.config file, as... <legacyUnhandledExceptionPolicy enabled="1"/>This link explains it: http://msdn2.microsoft.com/en-us/lib...65(VS.80).aspx
I suggest only using this flag when using 3rd party libraries that you cannot get fixed: there's never a good reason to use it for your own code.
Thanks, thats exactly what I'm after.
I can see the point about not using this flag out of principle, but at
present I have an app that has a couple of months of new development in
2.0 and will take another couple of months of make bug free in 2.0,
faced with a choice between rolling back 2 months work, repeating and
spending 2 months fixing bugs before getting onto 2.0 and using a flag
to allow me to continue using the newer version while fixing the bugs,
I'm happy using the flag. This discussion thread is closed Replies have been disabled for this discussion. Similar topics
3 posts
views
Thread by Professor Frink |
last post: by
|
4 posts
views
Thread by Craig831 |
last post: by
|
1 post
views
Thread by mike |
last post: by
|
5 posts
views
Thread by Dave Stewart |
last post: by
|
5 posts
views
Thread by Lucvdv |
last post: by
|
5 posts
views
Thread by Samuel R. Neff |
last post: by
|
5 posts
views
Thread by Simon Tamman {Uchiha Jax} |
last post: by
|
1 post
views
Thread by Bob |
last post: by
|
5 posts
views
Thread by =?Utf-8?B?c3VydHVyeg==?= |
last post: by
| | | | | | | | | | |