Skip to content

Instantly share code, notes, and snippets.

@PyroGenesis
Last active May 6, 2024 06:37
Show Gist options
  • Save PyroGenesis/05bd414d580ef662a4d50120ea9643f4 to your computer and use it in GitHub Desktop.
Save PyroGenesis/05bd414d580ef662a4d50120ea9643f4 to your computer and use it in GitHub Desktop.
Instructions for dumping stack information of Winforms application using WER

Instructions

  1. Follow the instructions here to enable WER. Make sure the DumpType is set to 2 (Full Dumps).
  2. Make a new Module (static Class in C#) called ProgramEntryPoint.
  3. Copy the code written below and don't forget to change YOUR_STARTUP_FORM_NAME_HERE.
  4. Change project configuration to Debug
  5. Go to Project Properties. In the Application tab, uncheck "Enable application framework".
  6. Change Startup Object to Sub Main.
  7. Go to Debug -> Windows -> Exception Settings and make sure Common Language Runtime Exceptions is checked (full checked and not partially checked).
  8. Now whenever an unhandled exception occurs, your application will quit and a .dmp file will be created in the folder specified in the DumpFolder registry key.
  9. Open the .dmp file in Visual Studio
  10. Click on "Set symbol paths". Make sure Microsoft Symbol Servers is enabled and add the path to your PDB files as well.
  11. Click on Debug with Mixed. If you've followed all the instructions, it should take you right to the line in the source code where the exception occurs with all variables and stack trace intact.
Module ProgramEntryPoint
<STAThread()>
Sub Main(args As String())
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException)
Application.Run(New YOUR_STARTUP_FORM_NAME_HERE)
End Sub
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment