Skip to content

Commit d5b399b

Browse files
authored
Merge pull request #15115 from Mikejo5000/mikejo-br28
Updated steps for article on JIT debugging
2 parents a3182a6 + f15af32 commit d5b399b

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

docs/debugger/debug-using-the-just-in-time-debugger.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Debug using the Just-In-Time Debugger
33
description: Debug using the Just-In-Time Debugger in Visual Studio. Just-In-Time debugging can launch Visual Studio automatically when an app returns errors or crashes.
4-
ms.date: 1/16/2026
4+
ms.date: 3/9/2026
55
ms.topic: how-to
66
f1_keywords:
77
- "VS.ToolsOptionsPages.Debugger.JIT"
@@ -57,7 +57,7 @@ When you work with the Just-In-Time debugger in Visual Studio, configuration opt
5757

5858
:::moniker-end
5959

60-
If you enable the Just-In-Time debugger, but it doesn't open when an app crashes or errors, see [Troubleshoot Just-In-Time debugging](#jit_errors).
60+
If you enable the Just-In-Time debugger, but it doesn't open when an app crashes or errors, see [Troubleshoot Just-In-Time debugging](#troubleshoot-just-in-time-debugging).
6161

6262
## Disable Just-In-Time debugging from the Windows registry
6363

@@ -99,7 +99,7 @@ By default, Windows Form apps have a top-level exception handler that lets the a
9999

100100
To enable Just-In-Time debugging instead of standard Windows Form error handling, add these settings:
101101

102-
- In the `system.windows.forms` section of the *machine.config* or *\<app name>.exe.config* file, set the `jitDebugging` value to `true`:
102+
- In the `system.windows.forms` section of the *machine.config* or *bin\<app name>.exe.config* file, set the `jitDebugging` value to `true`:
103103

104104
```xml
105105
<configuration>
@@ -127,15 +127,23 @@ For this example, you make a C# console app in Visual Studio that throws a [Null
127127

128128
1. In Visual Studio, create a C# console app (**File** > **New** > **Project** > **Visual C#** > **Console Application**) named *ThrowsNullException*. For more information about creating projects in Visual Studio, see [Walkthrough: Create a simple application](../get-started/csharp/tutorial-wpf.md).
129129

130-
1. When the project opens in Visual Studio, open the *Program.cs* file. Replace the Main() method with the following code, which prints a line to the console and then throws a NullReferenceException:
130+
1. When the project opens in Visual Studio, open the *Program.cs* file. Replace any default code, including the Main() method, if present, with the following code. The following code prints a line to the console and then throws a NullReferenceException:
131131

132+
:::moniker range="visualstudio"
133+
```csharp
134+
Console.WriteLine("we will now throw a NullReferenceException");
135+
throw new NullReferenceException("this is the exception thrown by the console app");
136+
```
137+
::: moniker-end
138+
:::moniker range="<=vs-2022"
132139
```csharp
133140
static void Main(string[] args)
134141
{
135142
Console.WriteLine("we will now throw a NullReferenceException");
136143
throw new NullReferenceException("this is the exception thrown by the console app");
137144
}
138145
```
146+
::: moniker-end
139147

140148
1. To build the solution, choose either the **Debug** (default) or **Release** configuration, and then select **Build** > **Rebuild Solution**.
141149

@@ -158,7 +166,7 @@ For this example, you make a C# console app in Visual Studio that throws a [Null
158166

159167
For more information about build configurations, see [Understanding build configurations](../ide/understanding-build-configurations.md).
160168

161-
1. Open the built app *ThrowsNullException.exe* in your C# project folder (*...\ThrowsNullException\ThrowsNullException\bin\Debug* or *...\ThrowsNullException\ThrowsNullException\bin\Release*).
169+
1. Open the built app *ThrowsNullException.exe* in your C# project folder (*...\ThrowsNullException\ThrowsNullException\bin\Debug* or *...\ThrowsNullException\ThrowsNullException\bin\Release*), or run the executable from a command line.
162170

163171
You should see the following command window:
164172

@@ -170,6 +178,9 @@ For this example, you make a C# console app in Visual Studio that throws a [Null
170178

171179
Under **Available Debuggers**, select **New instance of \<your preferred Visual Studio version/edition>**, if not already selected.
172180

181+
>[!NOTE]
182+
> If you don't see the Just-in-Time Debugger dialog box, you might need to add registry keys. See [Just-In-Time debugging fails to start](#troubleshoot-just-in-time-debugging)
183+
173184
1. Select **OK**.
174185

175186
The ThrowsNullException project opens in a new instance of Visual Studio, with execution stopped at the line that threw the exception:
@@ -181,7 +192,7 @@ You can start debugging at this point. If you're debugging a real app, you need
181192
> [!CAUTION]
182193
> If your app contains untrusted code, a security warning dialog box appears, enabling you to decide whether to proceed with debugging. Before you continue debugging, decide whether you trust the code. Did you write the code yourself? If the application is running on a remote machine, do you recognize the name of the process? If the app is running locally, consider the possibility of malicious code running on your computer. If you decide the code is trustworthy, select **OK**. Otherwise, select **Cancel**.
183194
184-
## <a name="jit_errors"></a> Troubleshoot Just-In-Time debugging
195+
## Troubleshoot Just-In-Time debugging
185196

186197
### Just-In-Time debugging fails to start
187198

@@ -191,9 +202,9 @@ If Just-In-Time debugging doesn't start when an app crashes, even though it's en
191202

192203
The fix is to add a **DWORD Value** of **Auto**, with **Value data** of **1**, to the following registry keys:
193204

194-
- **HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug**
205+
- (.NET) **HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug**
195206

196-
- (For 32-bit apps on 64-bit machines) **HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug**
207+
- (.NET Framework) **HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug**
197208

198209
- Windows Error Reporting could be taking over the error handling on your computer.
199210

13.4 KB
Loading

0 commit comments

Comments
 (0)