Imports System.Threading
Public Class Program
_
Shared Sub Main()
' ThreadExceptionCxgEnhðo^·é
AddHandler Application.ThreadException, AddressOf Application_ThreadException
' UnhandledExceptionCxgEnhðo^·é
AddHandler Thread.GetDomain().UnhandledException, AddressOf Application_UnhandledException
' CEXbhÈOÌáOÍUnhandledExceptionÅnh·é
'Dim buffer As String = "1"
'Dim [error] As Char = buffer.Chars(2)
' ±±ÅÀs³êéCEAvP[VEXbhÌáOÍ
' Application_ThreadExceptionÅnhÅ«é
Application.Run(New Form1)
End Sub
' ¢áOðLb`·éCxgEnhiWindowsAvP[Vpj
Public Shared Sub Application_ThreadException(ByVal sender As Object, ByVal e As ThreadExceptionEventArgs)
ShowErrorMessage(e.Exception, "Application_ThreadExceptionÉæéáOÊmÅ·B")
End Sub
' ¢áOðLb`·éCxgEnhiåÉR\[EAvP[Vpj
Public Shared Sub Application_UnhandledException(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
Dim ex As Exception = CType(e.ExceptionObject, Exception)
If Not ex Is Nothing Then
ShowErrorMessage(ex, "Application_UnhandledExceptionÉæéáOÊmÅ·B")
End If
End Sub
' [U[EthÈ_CAOð\¦·é\bh
Public Shared Sub ShowErrorMessage(ByVal ex As Exception, ByVal extraMessage As String)
MessageBox.Show(extraMessage & vbLf & "\\\\\\\\" & vbLf & vbLf & _
"G[ª¶µÜµ½BJ³É¨mç¹¾³¢" & vbLf & vbLf & _
"yG[àez" & vbLf & ex.Message & vbLf & vbLf & _
"yX^bNg[Xz" & vbLf & ex.StackTrace)
End Sub
End Class