473,851 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stopping application crashing when there is an unhandled exception

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.

Jan 4 '07 #1
20 11495
<jo************ **@hotmail.comw rote in message
news:11******** *************@s 34g2000cwa.goog legroups.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_Err or
routine...?
Jan 4 '07 #2

Mark Rae wrote:
<jo************ **@hotmail.comw rote in message
news:11******** *************@s 34g2000cwa.goog legroups.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_Err or
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.Curr entDomain.Unhan dledException" 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.

Jan 4 '07 #3
<jo************ **@hotmail.comw rote in message
news:11******** *************@1 1g2000cwr.googl egroups.com...
It handles the "AppDomain.Curr entDomain.Unhan dledException" 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
Jan 4 '07 #4
<jo************ **@hotmail.comw rote in message
news:11******** *************@1 1g2000cwr.googl egroups.com...
>
Mark Rae wrote:
><jo*********** ***@hotmail.com wrote in message
news:11******* **************@ s34g2000cwa.goo glegroups.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_Err or
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.Curr entDomain.Unhan dledException" 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.

Jan 4 '07 #5
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
Jan 4 '07 #6

Mark Rae wrote:
<jo************ **@hotmail.comw rote in message
news:11******** *************@1 1g2000cwr.googl egroups.com...
It handles the "AppDomain.Curr entDomain.Unhan dledException" 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

Jan 4 '07 #7
"Marc Gravell" <ma**********@g mail.comwrote in message
news:ud******** ******@TK2MSFTN GP04.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...
Jan 4 '07 #8
You should handle unhandled exceptions :).

Code in your Program class will be like this:
//Main method:

Application.Thr eadException += new
ThreadException EventHandler(On ThreadException );
AppDomain.Curre ntDomain.Unhand ledException +=
new UnhandledExcept ionEventHandler (CurrentDomain_ UnhandledExcept ion);

Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Run (new formMDI());

//event handlers
private static void CurrentDomain_U nhandledExcepti on(object sender,
UnhandledExcept ionEventArgs e)
{
MessageBox.Show ("CurrentDomain _UnhandledExcep tion: " +
e.ExceptionObje ct);
}

private static void OnThreadExcepti on(object sender,
ThreadException EventArgs t)
{
MessageBox.Show ("OnThreadExcep tion: " + t.Exception);
}

Best Regards,
Boban

*** Sent via Developersdex http://www.developersdex.com ***
Jan 4 '07 #9

Boban Stojanovski wrote:
You should handle unhandled exceptions :).

Code in your Program class will be like this:
//Main method:

Application.Thr eadException += new
ThreadException EventHandler(On ThreadException );
AppDomain.Curre ntDomain.Unhand ledException +=
new UnhandledExcept ionEventHandler (CurrentDomain_ UnhandledExcept ion);

Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Run (new formMDI());

//event handlers
private static void CurrentDomain_U nhandledExcepti on(object sender,
UnhandledExcept ionEventArgs e)
{
MessageBox.Show ("CurrentDomain _UnhandledExcep tion: " +
e.ExceptionObje ct);
}

private static void OnThreadExcepti on(object sender,
ThreadException EventArgs t)
{
MessageBox.Show ("OnThreadExcep tion: " + t.Exception);
}

Best Regards,
Boban

*** Sent via Developersdex http://www.developersdex.com ***
I have similar code in my app, but after the UnhandledExcept ion 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

Jan 4 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2961
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms application that is going to be used to extract data from a legacy system (VSAM based mainframe file structure), and output data in pipe-delimited record layouts, multiple record types per file, one file per chosen client. I have been working on...
4
2257
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms application that is going to be used to extract data from a legacy system (VSAM based mainframe file structure), and output data in pipe-delimited record layouts, multiple record types per file, one file per chosen client. I have been working on...
1
2111
by: mike | last post by:
My program is crashing, but it doesn't crash on a single line of code. Below is what the output tab displays. I have no idea where to start inorder to debug this problem. Is there any suggesstions on how to start debuging the problem 'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded 'StoredProcedure': Loaded 'N:\Dev\Programs\MNTEST3.net\Template.NET\bin\StoredProcedure.exe', No symbols...
5
2072
by: Dave Stewart | last post by:
I recently wrote my first Vb.net application, or at least my first complex app since moving up from vb6. When run from the VS.NET IDE, the program shows no errors and runs fine. When the output exe is run(this is a windows application) on my development pc, the exe runs fine as well. When the application is deployed on any other machine with .net framework 1.1, it generates an unhandled exception prioir to loading anything. The setup project...
5
5757
by: Lucvdv | last post by:
Can someone explain why this code pops up a messagebox saying the ThreadAbortException wasn't handled? The first exception is reported only in the debug pane, as expected. The second (caused by thread.Abort()) is reported twice: once in the debug window, and once through the message box. Is it because the thread was sleeping when the exception occurred?
5
3317
by: Samuel R. Neff | last post by:
When you have an unhandled exception in vb.net how do you view the exception information in the debugger? In C# the debugger creates a local variable that points to the exception and you can view it in one of the windows (autos or locals, don't remember which). That doesn't appear to be the case with vb.net. I also tried using the command window to inspect "Err" but that gave nothing useful (always empty).
5
3408
by: Simon Tamman {Uchiha Jax} | last post by:
Now this is bugging me. I just released software for a client and they have reported an unhandled stack overflow exception. My first concern is that the entirity of the UI and any threaded operations are all within Try Catches to help me locate the problem and the origination of any problem by specifiying an error code in the "Catch" section. So theoretically this shouldn't have been possible (at which point we all say "yeah,...
1
6324
by: Bob | last post by:
In Vs 2005 you have new applicationsEvents.vb I was testing it in a simple app and found that it was easier to implement unhandled exception management tah it was in Vs2003 (vb.net) You can, if you want to, prevent your app from terminating on an unhandled exception, and for me this is important. In an Ivr app it will let me hang up the phone only on the line that triggered the unhandled exception, leaving other callers to complete their...
5
5174
by: =?Utf-8?B?c3VydHVyeg==?= | last post by:
Hi, I feel like a noob for asking this. When I publish a VB windows application, I want to disable the ability of the the user to continue when there is an unhandled exception. For example, if there is a bug in the program that causes an exception, I want the program to crash. If there is an unhandled exception the program is in an undefined state, and continuing could be dangerous. I'm surprised the
0
9895
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11011
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10670
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7900
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7072
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5735
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5931
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4142
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.