Skip to content
BugSplat-GitPublic

About

πŸ›πŸ”πŸ§‘β€πŸ”¬ Collection of BugSplat for Windows C++ sample applications

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

bugsplat-github-banner-basic-outline

BugSplat

Crash and error reporting built for busy developers.

Follow @bugsplatco on Bluesky Join BugSplat on Discord

Introduction πŸ‘‹

This repository contains sample applications demonstrating how to integrate BugSplat crash reporting into Windows C++ and .NET applications.

C++ samples, using BugSplat.h:

  • MyConsoleCrasher - A console application demonstrating BugSplat integration with various crash types
  • MyCrasher - An ATL/MFC Windows application sample
  • MyWinUI3Crasher - A WinUI 3 application sample (requires WER configuration to work properly)

.NET samples, using BugSplatDotNet.dll (see .NET Samples):

  • MyDotNetCrasher - A .NET 10 console application with crash, error, and user feedback modes
  • MyDotNetWinUI3Crasher - A .NET 10 WinUI 3 application sample
  • MyDotNetFrameworkWpfCrasher - A .NET Framework 4.7.2 WPF application sample
  • MyDotNetFrameworkHostCrasher - A native C++ application that hosts the .NET Framework runtime and crashes in C# code
  • MyDotNetCrasherNative - The native DLL the .NET samples call to produce mixed-mode C#/C++ crashes

The samples build against the BugSplat for Windows SDK (9.3.0) in the BugSplat folder:

BugSplat/
  inc/                      BugSplat.h (C++ API), BugSplatC.h (C API), BugSplatVersion.h
  <platform>/<config>/      platform: x64, ARM64, Win32; config: Release, Debug
    bin/                    runtime files to ship next to your .exe: BugSplatMonitor.exe,
                            BugSplatReporter.exe, BugSplatWer.dll, BugSplat.dll, their PDBs,
                            and the optional BugSplatTheme/ folder for the crash dialog
    lib/md/BugSplat.lib     static library, /MD (dynamic CRT)
    lib/mt/BugSplat.lib     static library, /MT (static CRT)
    lib/dll/BugSplat.lib    import library for bin/BugSplat.dll
  dotnet/<config>/<tfm>/    BugSplatDotNet.dll for net10.0 and net472, with its PDB and XML docs

Each sample follows similar integration patterns. Detailed instructions are provided below for MyConsoleCrasher, and the similar principles apply to the other samples. Note that MyWinUI3Crasher requires Windows Error Reporting (WER) to be configured via registry settings as described in the Integration section.

Sample Applications πŸ§‘β€πŸ«

The following steps demonstrate how to get up and running with the MyConsoleCrasher sample application.

  1. Open MyConsoleCrasher.sln with Visual Studio 2022 or later, with the Desktop development with C++ workload. The samples use the MSVC v143 build tools, which Visual Studio 2022 includes; in Visual Studio 2026, add the MSVC v143 component in the Visual Studio Installer
  2. Define values for BUGSPLAT_DATABASE, APPLICATION_NAME, and APPLICATION_VERSION in Samples\MyConsoleCrasher\MyConsoleCrasher.h
  3. Create a Client ID and Client Secret pair for your BugSplat database on the Integrations page
  4. Create a file Samples\MyConsoleCrasher\Scripts\env.ps1 and populate it with the following (being sure to substitute your your-client-id and your-client-secret values from the previous step):
$BUGSPLAT_CLIENT_ID = "your-client-id"
$BUGSPLAT_CLIENT_SECRET = "your-client-secret"
  1. Set the command-line arguments for the project to /MemoryException, or one of the other supported arguments from the sample's source code, to test various crashes. To set the command-line arguments, right-click the MyConsoleCrasher project and select Properties > Debugging > Command Arguments.
Visual Studio Project Properties
  1. Rebuild the project. A post-build step uploads its symbols with symbol-upload-windows.exe, which Tools\Get-SymbolUpload.ps1 downloads on the first build; to build without uploading, pass /p:PostBuildEventUseInBuild=false. Run the sample outside of the Visual Studio debugger (Ctrl+F5). This is important since the debugger interferes with the BugSplat library's exception handling. You should see a dialog such as that shown below:

BugSplat Crash Dialog

  1. Enter some descriptive text to help you identify the crash you are about to upload. Click the Send report button, and voilΓ ! The report will be sent! In the BugSplat web app, look for the crash report with the description you entered.

  2. Navigate to the BugSplat Dashboard and click the link in the ID column to view details about your crash, including the full symbolicated stack trace and various crash metadata.

Finally, experiment with other features of the library by examining the MyConsoleCrasher source code and supplying different command-line arguments.

.NET Samples 🟣

The .NET samples reference BugSplatDotNet.dll from BugSplat\dotnet\ and copy the native runtime (BugSplat.dll, BugSplatMonitor.exe, BugSplatReporter.exe and BugSplatWer.dll) from BugSplat\x64\ next to the app. Each sample has its own solution and README with setup and run instructions:

Sample Solution Runtime
MyDotNetCrasher MyDotNetCrasher.sln .NET 10 console
MyDotNetWinUI3Crasher MyDotNetWinUI3Crasher.sln .NET 10 WinUI 3
MyDotNetFrameworkWpfCrasher MyDotNetFrameworkWpfCrasher.sln .NET Framework 4.7.2 WPF
MyDotNetFrameworkHostCrasher MyDotNetFrameworkHostCrasher.sln Native C++ hosting .NET Framework 4.7.2

As with the C++ samples, set your database in the sample's source, add your Client ID and Client Secret to the sample's Scripts\env.ps1 so that the build uploads symbols, and run outside the debugger.

The mixed-mode modes in MyDotNetCrasher, MyDotNetWinUI3Crasher and MyDotNetFrameworkWpfCrasher call into MyDotNetCrasherNative, which is built by the same solutions.

Integration πŸ—οΈ

This section explains how to modify your Microsoft Visual C++ application to upload crashes with full debug information to the BugSplat web application. Before getting started, please download the BugSplat SDK for Windows by clicking here.

Getting Started

Warning

For WinUI 3 applications (like MyWinUI3Crasher), BugSplat must be registered as a WER RuntimeExceptionModule. This process is demonstrated in our MyWinUI3Crasher sample project. The WER registry configuration is required for WinUI 3 applications to properly capture crashes. See the Registry Configuration section below for details.

Add BugSplat to your application using the following steps:

  1. Link with BugSplat.lib by adding an entry to Linker > Input > Additional Dependencies. Pick one flavor from lib\: md if your app builds with /MD, mt if it builds with /MT, or dll to load BugSplat.dll, whose C API (BugSplatC.h) works with either CRT.

  2. Add redistributable files from bin\ to your application's installer:

    • BugSplatMonitor.exe
    • BugSplatReporter.exe, which shows the crash dialog
    • BugSplatWer.dll
    • BugSplat.dll, if you linked lib\dll\BugSplat.lib
    • the BugSplatTheme folder, if you customize the crash dialog
  3. Ensure your installer runs with Administrator privileges and creates a RuntimeExceptionHelperModules registry key with a name containing the full path to BugSplatWer.dll. For more information about configuring WER see this doc.

  4. Include BugSplat.h in your application's source.

  5. Create an instance of BugSplat following the example in MyConsoleCrasher. The BugSplat constructor requires three parameters: database, application, and version. A new BugSplat database can be created on the Database page. Choose values for application name and version to match your product release. These same values are typically used when uploading symbol files for your application. To learn more about symbol uploads, please see our docs.

#include "BugSplat.h"

BugSplat g_BugSplat(BUGSPLAT_DATABASE, APPLICATION_NAME, APPLICATION_VERSION);
  1. Modify your build settings so that symbol files are created for release builds. Set C/C++ > General > Debug Information Format to Program Database /Zi. Be sure to also set Linker > Debugging > Generate Debug Info to Yes (/DEBUG).

  2. Configure a Post-Build step to upload your application's symbol files. Your script should authenticate using OAuth Client Credentials. You can create credentials on the Integrations page under the OAuth tab.

symbol-upload-windows.exe -b your-database -a your-app -v your-version -i your-client-id -s your-client-secret -d "$(OutputDir)\"

To get complete symbolicated call stacks and variable names for each crash, you should upload all **.exe**, **.dll**, and **.pdb** files for your product every time you build a release version of your application for distribution or internal testing.

Registry Configuration

Warning

The registry configuration below is required for WinUI 3 applications (like MyWinUI3Crasher) to properly capture crashes. It's also recommended for other application types to ensure all crash types are captured.

To enable BugSplat to register for WER callbacks, register the BugSplatWer.dll module as shown below. This registry entry should be a DWORD whose name is the path to the BugSplatWer.dll file installed in the same location as your executable. The value should be 0.

Create the WER registry key at the following location:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\RuntimeExceptionHelperModules

Here is that value shown highlighted in the registry editor for one of our sample applications:

BugSplat WER Registry Settings

By default, WER will stop creating crash dumps after it has seen a few of the same type. To disable this, create the following registry key:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\{Application Name}

Add the following values under the new key you created:

Registry Key Setting Description Value
DumpType Sets the type of dump to create. 0
DumpCount Sets the maximum number of dumps. 0

Here's an example of this shown in the registry editor:

LocalDumps Registry Configuration

For additional information, see Windows Error Reporting Settings

Verification

Test your application by forcing a crash.

*(volatile int *)0 = 0;

Verify that the BugSplat dialog appears, and that crashes are posted to your BugSplat account. Ensure that symbol names in the call stack are resolved correctly. If they aren't, double-check that the correct version of symbol files and all executables for your application have been uploaded to BugSplat.

If everything is configured correctly, you should see a crash report that resembles this one in your BugSplat database.

BugSplat Crash Page

Crash Dialog

Instructions for modifying the default crash dialog can be found on the Windows Dialog Box page.

Additional Resources πŸ“š

Updating the Samples πŸ”„

This repository is the contents of the BugSplat.zip and BugSplatDotNet.zip assets from a bugsplat-windows release. To update it to a new release:

  1. Download both zips from the release
  2. Extract BugSplatDotNet.zip over the repository, then BugSplat.zip. Both zips contain the x64 runtime, signed separately, so extracting BugSplat.zip last keeps those binaries the same as the C++ SDK's
  3. Delete Samples/MyWinUI3Crasher/MyWinUI3Crasher/Scripts/Prepare.ps1 if the zip includes it. It is a release build script, and bugsplat-windows#264 removes it from the zip
  4. Update the version in this README, then commit everything except Tools/symbol-upload-windows.exe, which .gitignore excludes

License πŸͺͺ

See LICENSE file for details.

About

πŸ›πŸ”πŸ§‘β€πŸ”¬ Collection of BugSplat for Windows C++ sample applications

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages