Application.ThreadException vs AppDomain.UnhandledException

前端 未结 3 1628
谎友^
谎友^ 2020-12-31 10:10

First some background: I have a multi-threaded WinForms application that is doing interop to native dlls. This application crashes sometimes with unhandled exception and we

3条回答
  •  感情败类
    2020-12-31 10:47

    I highly recommend that you use the OS minidump generation instead of your own. This is for several reasons:

    1. Generating a minidump from within the same process is extremely problematic and not always possible.
    2. By the time ThreadException or UnhandledException is started, the exception stack has already been unwound. Generating a minidump at that point will just point you to the handler, not the source of the exception.

    If your app is in the field, use WER. If you're doing in-house testing, use ProcDump. You can also just copy the minidump file while the Error Reporting dialog is active.

    P.S. There are some exceptional conditions - most notably when doing p/Invoke - where neither ThreadException nor UnhandledException will work.

    P.P.S. If you have a debuggable scenario, then try turning on the Managed Debugging Assistants relating to p/Invoke.

提交回复
热议问题