HelloBacktrace – A guide to Crash and Error Reporting with C++, C#, and Mixed call stacks


A brief guide to create simple C++, C# and mixed call stack programs integrated with Backtrace


This series will walk readers through a step by step process to create and run programs that can report crashes and exceptions to Backtrace.

Step 0: Prerequisites

Before you can get started building these programs, you’ll need the following:

  • An account with Backtrace (in order to submit and view the crashes/exceptions).
  • If you are going to work on the C# and Mixed call stacks, you’ll need a 2.0+ .NET Core framework.

For the C++ macOS program, you’ll also need a local Crashpad build.

Additionally, the examples are laid out for users using Visual Studio and Xcode (for macOS) but other IDE’s will work as well.

If you already have these, skip this section! If not, steps to set them up are below.

  1. Create a Backtrace account and generate an error submission token
    1. Create a Backtrace account here
    2. You’ll get an email with instructions on where to log in
    3. Once you log in, you’ll be prompted to create a project. Then you can open the menu options (click on the gray circle in the top right of the home page) and select Project Settings
    4. Select error submission in the menu on the left side of the screen, and then the plus sign to generate a new token for the project
    5. Save these for later!
  2. .NET Core framework (2.0+)
    Windows and macOS: download here
  3. Local Crashpad build
    Windows: Unnecessary
    macOS: brief instructions included in C++ section
  4. Visual Studio
    Windows: download here
    Use the Backtrace Visual Studio Extension to easily get started with Crashpad
  5. Xcode
    Windows: Unnecessary
    macOS: download here



  1. Open Visual Studio and create a new project, selecting C++ and Console App in template options

    1. From the Tools menu, open the Extensions, search for Backtrace and install Backtrace extension
    2. Right click on the project to open the project menu and select Add Crashpad support, then step through configuration wizard (more info here)
    3. View CrashpadSetup.cpp – Specify db_path and handler_path (Be sure to escape backslashes) – Example:

      Note that rate limiting should be checked for production apps
    4. Replace contents of CrashpadSetup.cpp with the code below:

  1. Build in VS
  1. Run in Powershell

  1. View your error(s) in Backtrace!

For more information, see our Crashpad integration guide.


Additional Prereq: Crashpad Build

Steps to build crashpad locally on macOS are listed below. If you’re already set up with Crashpad, skip ahead to the next section.

  1. Get and build depot_dools (more info). In terminal, open and run
  2. Get and build crashpad
  3. Replace Crashpad’s library with Backtrace’s fork
    1. In a separate directory, git clone https://github.com/backtrace-labs/crashpad.git
    2. Copy the Backtrace library into ~/crashpad/crashpad and override the existing files
  4. Run gclient sync
  5. Build again

Note: if the Crashpad build has never been used before, you’ll also need to create and configure the Crashpad database. To do so, run the two commands below in the directory containing crashpad_database_util

Once Crashpad is all set, follow the steps below.

  1. Open XCode
  2. Create a new project (File >> New Project), select macOS Command Line Tool in the template options and C++ for language
  3. Name the project, select or create a directory for the project to live and save
  4. Replace main.cpp with the following (be sure to fill in the file paths, token and submission URL appropriately)

  5. Link libraries, compile and run
  6. View your error(s) in Backtrace! For more information, see our Crashpad integration guide.



  1. Open Visual Studio and create a new project, selecting C#, Windows Desktop and Console App (.NET Framework) in the template options
  2. From the Tools menu, under NugGet Package Manager select Manage NuGet Packages for Solution. Under the Browse tab, search for and install Backtrace
  3. Within Program.cs, replace your main() with [example code from below]. Fill in your token and submission URL appropriately, and make sure the following is added as well:
  4. Build in VS
  5. Run in Powershell
  6. View your errors in Backtrace!

Here is the code to place in main()


For more information, see our C# integration guide and our library’s ReadMe


  1. Create a new Visual Studio solution, selecting a .NET Console Project (C#)
  2. Select Console Application and .Net Core App in the template options
  3. Install Backtrace via NuGet
    1. Project >> Add NuGet Package >> Search for Backtrace >> Check and click “Add Package”
    2. Or in terminal, cd to your project’s directory and run

  4. Replace Program.cs with [same example code from Windows above]
    1. Be sure to fill in the token and submission URL appropriately
  5. Build and run in VS
  6. View your errors in Backtrace!

For more information, see our C# integration guide and our library’s ReadMe

Mixed Call Stacks


      1. For template select Visual C#, Windows Desktop, Console App (.NET Framework)
      2. Right click solution and click add >> project
        1. For template select Visual C++, Windows Desktop, DLL
      3. If you do not already have the Backtrace Visual Studio Crashpad Extension, download and install it
        1. Tools >> Extensions >> Search for Backtrace >> select and install Backtrace extensions
      4. Right click the newly created DLL project and select add crashpad support
        1. Enter submission URL and token and click through install (more details here)
      5. Open CrashpadSetup.cpp and replace database and handler path values
        1. These will be in the bin folder of your crashpad build (be sure to escape backslashes)
      6. Replace Dll1.cpp with example code
      7. Replace Crashpad.hpp with example code:

      8. Right click Dll1 project in solution explorer and build
      9. Add Backtrace NuGet package to C# project – Tools >> NuGet Package Manager >> Manage Packages for Solutions >> Search for and Install Backtrace
      10. Open C# project’s Program.cs and replace with example code

      11. Build
      12. Copy the C++ project’s DLL into the bin directory where the C# project .exe lives
      13. Open powershell and run the C#’s project .exe

View your errors in Backtrace!

The quickest way to see these incoming errors is the Explore Tool -> List view. As seen in the video below, you can add the columns timestamp, application, error message and callstack, amongst other attributes. By doing so, you can see reports from C# and C++ components side by side.

For more information, see our Mixed Callstack Integration Guide and a video demo here

By | 2020-10-03T02:50:04+00:00 May 21st, 2019|Backtrace, How To|