Generate / create mdump files for in my app

前端 未结 2 2039
天命终不由人
天命终不由人 2021-02-04 15:28

Im looking for a way to generate minidump files in my applications simular to what ProcDump does but prefarably with code and not having to extract a 3dparty tool to do it.

2条回答
  •  日久生厌
    2021-02-04 16:21

    You can call MiniDumpWriteDump from AppDomain.UnhandledException or Application.ThreadException event handler to create the minidump. This article explains the function in great details: Effective minidumps

    You can also use this library which has other functionality too: Catch All Bugs with BugTrap!

    Edit

    Looks like getting a useful minidump is not that easy. First of all sos.dll complains when the dump is not full (full dumps are about 100-150MB). Secondly, writing dump in catch block is not recommended: Getting good dumps when an exception is thrown.

    If you have a winforms application this question has some usefull info: How does SetUnhandledExceptionFilter work in .NET WinForms applications?

提交回复
热议问题