Implementing Windows Error Reporting RRS feed

  • Question

  • Hi there

    From the link below I can see that there is one line of code that must be added in order to support Windows Error Reporting:

    The problem with calling the line above (Application.SetUnhandledExceptionMode....) is that you need to do it before creating any window handles. The answer is creating a Main Sub as shown below:

     Public Sub Main()
            Application.Run(New frmMain)
        End Sub
    The problem with doing this is that
    you need to disable the application framework as you need to specify a startup object (Sub Main) and not a form (frmMain). This in turn leads to other problems. We have now picked up an issue where MDI forms that are opened from dialog forms just do not open when the application framework is disabled.

    So my question is, is there another way of setting the UnhandledExceptionMode of the application to ThrowException where the Application Framework is still enabled. I have found references on the internet to a line which can be added to the app.config file (<legacyUnhandledExceptionPolicy enabled="1" />), but this does not seem to have any effect.

    Any help in this regard will be greatly appreciated.



    • Moved by Max Wang_1983 Tuesday, April 26, 2011 2:07 AM forum consolidation (From:Windows Error Reporting for ISVs)
    Friday, November 20, 2009 11:02 AM

All replies

  • Johan,

    Can you be more specific with regard to "disable the application framework"? Where are you specifying the startup object Sub Main? I'm definitely not a WinForms expert but if I create a simple WinForms project, Sub Main exists and is the entry point of the application. I.e. I didn't have to create a Sub Main, it was created for me and should run before any windows are created. Can you help us understand how your scenario differs from the default?

    Regarding legacyUnhandledExceptionPolicy: This won't help you here. That tells any V2+ runtime to do what V1 did which was to silently swallow unhandled exceptions on background managed threads. While this may prevent your application from crashing, it has nothing to do with what will happen when it does crash (e.g. from an unhandled exception on the main thread or a native thread) and it can often lead to unexpected application behavior since you've just allowed your program to continue executing after something rather unexpected has occurred.


    Wednesday, December 2, 2009 5:20 AM
  • Hi Jon

    Thanks for the reply.

    If I create a new Windows Forms Application in VS2008 Development Edition (VB)  it only has a form (Form1) which is also by default specified as the Startup Form (in Project Properties). In order to specify a Sub Main as the Startup Object I need to untick the "Enable Application Framework" option. I see the project properties for a C# project is completely different and that a Sub Main is specified by default as the entry point. There isn't even a "Enable Application Framework" option.

    We have done the above and created a Sub Main as the entry point for the application. This is fine,but as I mentioned, there are some weird behaviour as a result of having to untick the "Enable Application Framework" option. Our application has a MDI interface and in various places we present the user with a dialog window which then opens a MDI window if the user proceeds. These windows simply do not open when the Application Framework is disabled.

    So, it comes down to this. How do I specify a Sub Main as the entry point for a VB application without having to untick the "Enable application framework" option?

    Tuesday, December 8, 2009 9:34 AM
  • I'd appreciate some help with this same issue.
    Thursday, December 31, 2009 9:29 PM