Open the project properties. On the "Application" tab, you click the "View
Application Events" button. That will generate a new partial class looking
like this:
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
End Class
End Namespace
Create a handler like this in the MyApplication class:
Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e
As Microsoft.VisualBasic.ApplicationServices.Unhandle dExceptionEventArgs)
Handles Me.UnhandledException
'My.Application.Log.WriteException(e.Exception, TraceEventType.Critical,
"Unhandled Exception.")
MsgBox("An unhandled exception occurred: " & e.Exception.Message &
vbCrLf & vbCrLf & "I'm going to quit now!")
End
End Sub
That should do it.
Cheers,
Johnny J.
"surturz" <su*****@newsgroup.nospamwrote in message
news:FF**********************************@microsof t.com...
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
default is to give the user the option to continue, quite frankly. I'm
using
Visual Studio 2005.
Thanks,
-SurturZ