I have an application (code shown) that intercepts unhandled exceptions and displays a custom exception dialog, this may of of some help?
Imports BM.BEAST.Presenters
Imports BM.BEAST.Security
Imports BM.BEAST.Business
Imports System.Threading
Public Class StartUp
Shared Sub UnhandledException(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs)
Dim unhandledException As New UnhandledExceptionView
unhandledException.uxExceptionDetails.Text = e.Exception.ToString
unhandledException.ShowDialog()
If unhandledException.uxRestart.Checked Then
Application.Restart()
Else
Application.Exit()
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Entry point
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Shared Sub Main()
'All unhandled exceptions are handled by the sub UnhandledException()
'which displays a BEAST exception dialog and gives the user the chance
'to copy the error to clipboard for pasting into email etc..
AddHandler Application.ThreadException, AddressOf UnhandledException
'Application framework not enabled
My.User.InitializeWithWindowsUser()
'Users must be authenticated
If My.User.IsAuthenticated Then
Dim securityPrincipal As Security.ISecurityPrincipal = Nothing
Dim applicationController As ApplicationController = Nothing
Try
'Custom security principal for use throughout the session
securityPrincipal = ServiceGateway.Instance.StartUserSession
AppDomain.CurrentDomain.SetThreadPrincipal(securityPrincipal)
Thread.CurrentPrincipal = securityPrincipal
applicationController = applicationController.GetInstance
applicationController.RegisterNavigator(New ApplicationNavigator)
'If a user holds more than 1 role they will have to select
'the role they want applied for use throughout the session
If securityPrincipal.Roles.Count > 1 Then applicationController.NavigateTo("SelectRoleView")
applicationController.NavigateTo("ShellView")
Catch ex As Exceptions.InvalidUserNameException
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Invalid User")
Catch ex As Exceptions.UserDisabledException
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "User Disabled")
Catch ex As System.Net.Sockets.SocketException
MsgBox("The xxxxx Server is unavailable, contact the System Administrator.", MsgBoxStyle.Exclamation, "Server Unavailable")
End Try
Else
MsgBox("User not authenticated, the application will terminate.", MsgBoxStyle.Exclamation, "Authentication")
End If
My.Settings.Save()
Application.Exit()
End Sub
End Class