集約エラーハンドルを持つエントリポイント

Imports System.Security.Cryptography.X509Certificates
Imports Microsoft.VisualBasic.CompilerServices

Module startUp
''' <summary>
''' UserContext
''' </summary>
Public usContext As New UserContext
<STAThread()>
Sub Main()
' UIスレッドの集約例外ハンドラ
AddHandler Application.ThreadException, AddressOf Application_ThreadException
' UIスレッド以外の集約例外ハンドラ
AddHandler AppDomain.CurrentDomain.UnhandledException,
AddressOf CurrentDomain_UnhandledException

Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Login())
End Sub
Sub Application_ThreadException(sender As Object, e As System.Threading.ThreadExceptionEventArgs)
Utils.WriteSystemErrorLog(AppMessages.ERR_MAIN0001, e.Exception,, True)
End Sub

''' <summary>
''' UIスレッド以外の集約例外ハンドラ。
''' UnhandledException はアプリケーションが終了することを防止できない。
''' </summary>
Sub CurrentDomain_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs)
Utils.WriteSystemErrorLog(AppMessages.ERR_MAIN0001, CType(e.ExceptionObject, Exception),, True)
Environment.Exit(-1)
End Sub
End Module