473,382 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Application unhandled exception event question

Bob
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 calls.
This is the sample app code

In form1

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnTest.Click

'-- just a simple "object not initialized" exception (should read "as new")

Dim x As Specialized.NameValueCollection

MessageBox.Show(x.Count.ToString)

MessageBox.Show("Application is continuing")

End Sub

End Class

In application Events.vb

Namespace My

' The following events are availble for MyApplication:

'

' Startup: Raised when the application starts, before the startup form is
created.

' Shutdown: Raised after all application forms are closed. This event is not
raised if the application terminates abnormally.

' UnhandledException: Raised if the application encounters an unhandled
exception.

' StartupNextInstance: Raised when launching a single-instance application
and the application is already active.

' NetworkAvailabilityChanged: Raised when the network connection is
connected or disconnected.

Partial Friend Class MyApplication

Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e
As Microsoft.VisualBasic.ApplicationServices.Unhandle dExceptionEventArgs)
Handles Me.UnhandledException

MsgBox("Sender: " & sender.ToString & " Exception:" & e.Exception.Message)

e.ExitApplication = False

End Sub

End Class

End Namespace

Quite simple really and it seems to work OK. I have one problem, I would
like to be able to single step through the applicationEvents.vb code when it
is triggered in my IDE, like when I click the button in form1 while in the
IDE but I always get The exception dialog window that gives me info about
the unhandled application and I can only test if it works by running the
compiled exe, Only then do I see the message box un the unhandledexeception
event handler.

Is there any way that I could get to that code while in debug mode?

Thanks for any help

Bob


Jun 12 '06 #1
1 6281
On Mon, 12 Jun 2006 13:23:52 -0400, "Bob" <bd*****@sgiims.com> wrote:
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 calls.
This is the sample app code

In form1

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnTest.Click

'-- just a simple "object not initialized" exception (should read "as new")

Dim x As Specialized.NameValueCollection

MessageBox.Show(x.Count.ToString)

MessageBox.Show("Application is continuing")

End Sub

End Class

In application Events.vb

Namespace My

' The following events are availble for MyApplication:

'

' Startup: Raised when the application starts, before the startup form is
created.

' Shutdown: Raised after all application forms are closed. This event is not
raised if the application terminates abnormally.

' UnhandledException: Raised if the application encounters an unhandled
exception.

' StartupNextInstance: Raised when launching a single-instance application
and the application is already active.

' NetworkAvailabilityChanged: Raised when the network connection is
connected or disconnected.

Partial Friend Class MyApplication

Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e
As Microsoft.VisualBasic.ApplicationServices.Unhandle dExceptionEventArgs)
Handles Me.UnhandledException

MsgBox("Sender: " & sender.ToString & " Exception:" & e.Exception.Message)

e.ExitApplication = False

End Sub

End Class

End Namespace

Quite simple really and it seems to work OK. I have one problem, I would
like to be able to single step through the applicationEvents.vb code when it
is triggered in my IDE, like when I click the button in form1 while in the
IDE but I always get The exception dialog window that gives me info about
the unhandled application and I can only test if it works by running the
compiled exe, Only then do I see the message box un the unhandledexeception
event handler.

Is there any way that I could get to that code while in debug mode?

Thanks for any help

Bob


Have a look at:
Application.ThreadException

This event allows your Windows Forms application to handle otherwise
unhandled exceptions.
Gene
Jun 12 '06 #2

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

Similar topics

12
by: Rakesh | last post by:
Hi, I am catching unhandled exception by attached an event handler on the Application.ThreadException event. This will ensure that I could handle all uncaught exceptions on the main thread. ...
5
by: Jason MacKenzie | last post by:
I have a production critical windows forms application. I have try catch blocks everywhere to handle every eventuality. However occasionally, every couple of months, the application crashes. Its...
2
by: Alex | last post by:
My Problem is that although i have added a handler to Application.ThreadException and it works fine for my application exceptions, it does not fire if an exception is generated inside an event...
5
by: Nak | last post by:
Hi there, I have a very simple console application that I'm trying to handle the thread exception on, as I understand it there is no Application object available to a console application, so I...
5
by: Sam Loveridge | last post by:
Hi All. I'm hoping someone can point me in the direction of a solution to unhandled exceptions in MDI child forms causing the application to crash. I've found various articles describing a...
4
by: David Lozzi | last post by:
Howdy, I found a nice little book called ASP.NET 2.0 Cookbook by Michael A Kittel and Geoffrey LeBlond. Anyway, they have some instructions on how to setup application level error handling. Most...
0
by: Robert Dufour | last post by:
I have some things I need done in the application events unhandledexception event. I have some code in there whose execution I need to verify. In order to do that I wrote a simple button click...
5
by: Frank Rizzo | last post by:
I have a c# 2.0 winform app that runs under a user account with very limited rights. The application crashes on some actions (the Send Error to Microsoft screen) with unauthorized exception. ...
5
by: giddy | last post by:
hi, I made this little crash reporter system for my project. It works by getting hooked up to the Application.ThreadException event. If an unhandled exception occurs , it logs it and then puts...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.