A
Alex Glass
I am using a reference to a Library called MySql.Data in my application. If
I run my program on a computer that does not have the library installed, the
application throws an exception and a window pops up that says: "Application
has generated an exception that could not be handled". Is there any way to
capture this type of exception. I have tried using Try Catch blocks and
also the UnhandledException/UnhandledThreadException events without any
luck. Below is some code to clarify the problem.
The software I am using is can be found at
http://dev.mysql.com/downloads/connector/net/1.0.html
--------------------------------------------------------------------------------------------------------------------------
Module Startup
Public Sub Main()
Try
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf
UnhandledException
AddHandler Application.ThreadException, AddressOf
ThreadException
MsgBox("Creating Object")
Dim obj As MySql.Data.MySqlClient.MySqlConnection = New
MySql.Data.MySqlClient.MySqlConnection
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub UnhandledException(ByVal sender As Object, ByVal e As
UnhandledExceptionEventArgs)
MsgBox("An unhandled exception has occurred")
End Sub
Private Sub ThreadException(ByVal sender As Object, ByVal e As
Threading.ThreadExceptionEventArgs)
MsgBox("An unhandled exception has occurred")
End Sub
End Module
-------------------------------------------------------------------------------------------------------------------------
On the computer that does not have MySql.Data installed the program bypasses
the exception handlers and just displays the standard unhandled exception
window. If the line has no New statement the program runs without a
problem.
As in:
Dim obj As MySql.Data.MySqlClient.MySqlConnection
I suppose I could resort to using CreateObject but I would prefer to avoid
this if possible.
I run my program on a computer that does not have the library installed, the
application throws an exception and a window pops up that says: "Application
has generated an exception that could not be handled". Is there any way to
capture this type of exception. I have tried using Try Catch blocks and
also the UnhandledException/UnhandledThreadException events without any
luck. Below is some code to clarify the problem.
The software I am using is can be found at
http://dev.mysql.com/downloads/connector/net/1.0.html
--------------------------------------------------------------------------------------------------------------------------
Module Startup
Public Sub Main()
Try
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf
UnhandledException
AddHandler Application.ThreadException, AddressOf
ThreadException
MsgBox("Creating Object")
Dim obj As MySql.Data.MySqlClient.MySqlConnection = New
MySql.Data.MySqlClient.MySqlConnection
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub UnhandledException(ByVal sender As Object, ByVal e As
UnhandledExceptionEventArgs)
MsgBox("An unhandled exception has occurred")
End Sub
Private Sub ThreadException(ByVal sender As Object, ByVal e As
Threading.ThreadExceptionEventArgs)
MsgBox("An unhandled exception has occurred")
End Sub
End Module
-------------------------------------------------------------------------------------------------------------------------
On the computer that does not have MySql.Data installed the program bypasses
the exception handlers and just displays the standard unhandled exception
window. If the line has no New statement the program runs without a
problem.
As in:
Dim obj As MySql.Data.MySqlClient.MySqlConnection
I suppose I could resort to using CreateObject but I would prefer to avoid
this if possible.