Catching ThreadingException in VB.NET when Sub Main is not accessible...
I have a VB.NET winforms solution, and would like to add the standard application exception handlers - `Application.ThreadException` and `AppDomain.CurrentDomain.UnhandledException`.

I have the following code [from MSDN][1]

    ' Starts the application. '
    <SecurityPermission(SecurityAction.Demand, Flags:=SecurityPermissionFlag.ControlAppDomain)> _
    Public Shared Sub Main()
        ' Add the event handler for handling UI thread exceptions to the event. '
        AddHandler Application.ThreadException, AddressOf ErrorHandlerForm.Form1_UIThreadException
    
        ' Set the unhandled exception mode to force all Windows Forms errors to go through'
        ' our handler. '
        Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException)
    
        ' Add the event handler for handling non-UI thread exceptions to the event. '
        AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException
    
        ' Runs the application. '
        Application.Run(New ErrorHandlerForm())
    End Sub


How can I do it in VB.NET when I have no acces to the `Sub Main()` method?

Is the case when "Enable Application Framework" of my solution properties is enabled (`Sub Main` is hidden)...


  [1]: http://msdn.microsoft.com/fr-fr/library/system.windows.forms.application.threadexception.aspx
Catching ThreadingException in VB.NET when Sub Main is not accessible...
===

I have a VB.NET winforms solution, and would like to add the standard application exception handlers - `Application.ThreadException` and `AppDomain.CurrentDomain.UnhandledException`.

I have the following code [from MSDN][1]

    ' Starts the application. '
    <SecurityPermission(SecurityAction.Demand, Flags:=SecurityPermissionFlag.ControlAppDomain)> _
    Public Shared Sub Main()
        ' Add the event handler for handling UI thread exceptions to the event. '
        AddHandler Application.ThreadException, AddressOf ErrorHandlerForm.Form1_UIThreadException
    
        ' Set the unhandled exception mode to force all Windows Forms errors to go through'
        ' our handler. '
        Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException)
    
        ' Add the event handler for handling non-UI thread exceptions to the event. '
        AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException
    
        ' Runs the application. '
        Application.Run(New ErrorHandlerForm())
    End Sub


How can I do it in VB.NET when I have no acces to the `Sub Main()` method?

Is the case when "Enable Application Framework" of my solution properties is enabled (`Sub Main` is hidden)...


  [1]: http://msdn.microsoft.com/fr-fr/library/system.windows.forms.application.threadexception.aspx