B
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.UnhandledExceptionEventArgs)
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
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.UnhandledExceptionEventArgs)
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