> For the complete documentation index, see [llms.txt](https://docs.bugsplat.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bugsplat.com/getting-started/posting-a-test-crash/mydotnetframeworkhostcrasher.md).

# MyDotNetFrameworkHostCrasher (C++ hosting .NET Framework)

Testing crashes in .NET Framework code hosted by a native C++ application with the sample 'MyDotNetFrameworkHostCrasher'

`MyDotNetFrameworkHostCrasher` is for applications that are native C++ programs which load the .NET Framework and call into C# code. The sample's C++ program initializes the [BugSplat native SDK](/integrations/desktop/cplusplus.md), starts the .NET Framework 4.7.2 runtime, and calls into a C# library that crashes. The report's call stack shows the C# frames on top of the C++ program's own frames.

To get started, download the BugSplat SDK for .NET by clicking [here](https://app.bugsplat.com/browse/download_item.php?item=dotnet), then unzip it.

1. Open `MyDotNetFrameworkHostCrasher.sln` with Visual Studio 2022+.
2. Define a value for `BUGSPLAT_DATABASE` in `Samples\MyDotNetFrameworkHostCrasher\MyDotNetFrameworkHostCrasher.h`.
3. Create a Client ID and Client Secret pair for your BugSplat database on the [Integrations](https://app.bugsplat.com/v2/database/integrations#oauth) page.
4. Create a file `Samples\MyDotNetFrameworkHostCrasher\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):

```powershell
$BUGSPLAT_CLIENT_ID = "your-client-id"
$BUGSPLAT_CLIENT_SECRET = "your-client-secret"
```

5. Build the solution for **x64**. It builds the C# library (`MyDotNetFrameworkHostCrasherManaged`) and the C++ program, and a post-build step uploads their executables, DLLs, and `.pdb` files to BugSplat.
6. Run the program from a command prompt with one of the crash options below, outside of the Visual Studio debugger, for example:

```
MyDotNetFrameworkHostCrasher.exe /DeepThrow
```

| Option             | What happens in the C# code                                                       |
| ------------------ | --------------------------------------------------------------------------------- |
| `/Throw`           | Throws an unhandled exception.                                                    |
| `/DeepThrow`       | Throws an unhandled exception four methods deep.                                  |
| `/Thread`          | Throws an unhandled exception on a worker thread.                                 |
| `/AccessViolation` | Writes to an invalid address.                                                     |
| `/NativeCallback`  | Calls back into a C++ function in the host program that crashes (C++ → C# → C++). |
| `/NoCrash`         | Returns to the C++ program without crashing.                                      |

Add `/Quiet` to skip the crash dialog. Run the program with no arguments to see every option.

7. When the crash dialog appears, click **Send report**, then open the crash from the BugSplat [Dashboard](https://app.bugsplat.com/v2/dashboard) to see the combined C# and C++ call stack with file names and line numbers.

### How It Works

BugSplat is initialized in the C++ program, before the .NET Framework runtime starts, so its exception handling is in place when the C# code runs. The program calls `SetCrashType(8)`, which tells BugSplat to resolve the managed (C#) frames in its minidumps. To report crashes from your own C++ application that hosts .NET, follow [BugSplat for Windows (C++)](/integrations/desktop/cplusplus.md) and add that same call. If your application is a managed .NET Framework or .NET 10 program instead, use [BugSplat for .NET](/integrations/desktop/bugsplat-for-dot-net.md).

A stack overflow in the C# code isn't reported: the .NET Framework ends the process without running any exception handlers, and reports it only through its own Windows Error Reporting event.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.bugsplat.com/getting-started/posting-a-test-crash/mydotnetframeworkhostcrasher.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
