You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/debugger/debug-using-the-just-in-time-debugger.md
+19-8Lines changed: 19 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Debug using the Just-In-Time Debugger
3
3
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
5
5
ms.topic: how-to
6
6
f1_keywords:
7
7
- "VS.ToolsOptionsPages.Debugger.JIT"
@@ -57,7 +57,7 @@ When you work with the Just-In-Time debugger in Visual Studio, configuration opt
57
57
58
58
:::moniker-end
59
59
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).
61
61
62
62
## Disable Just-In-Time debugging from the Windows registry
63
63
@@ -99,7 +99,7 @@ By default, Windows Form apps have a top-level exception handler that lets the a
99
99
100
100
To enable Just-In-Time debugging instead of standard Windows Form error handling, add these settings:
101
101
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`:
103
103
104
104
```xml
105
105
<configuration>
@@ -127,15 +127,23 @@ For this example, you make a C# console app in Visual Studio that throws a [Null
127
127
128
128
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).
129
129
130
-
1. When the project opens in Visual Studio, open the *Program.cs* file. Replace the Main() methodwith 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:
131
131
132
+
:::moniker range="visualstudio"
133
+
```csharp
134
+
Console.WriteLine("we will now throw a NullReferenceException");
135
+
thrownewNullReferenceException("this is the exception thrown by the console app");
136
+
```
137
+
::: moniker-end
138
+
:::moniker range="<=vs-2022"
132
139
```csharp
133
140
staticvoidMain(string[] args)
134
141
{
135
142
Console.WriteLine("we will now throw a NullReferenceException");
136
143
thrownewNullReferenceException("this is the exception thrown by the console app");
137
144
}
138
145
```
146
+
::: moniker-end
139
147
140
148
1. To build the solution, choose either the **Debug** (default) or **Release** configuration, and then select **Build** > **Rebuild Solution**.
141
149
@@ -158,7 +166,7 @@ For this example, you make a C# console app in Visual Studio that throws a [Null
158
166
159
167
For more information about build configurations, see [Understanding build configurations](../ide/understanding-build-configurations.md).
160
168
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.
162
170
163
171
You should see the following command window:
164
172
@@ -170,6 +178,9 @@ For this example, you make a C# console app in Visual Studio that throws a [Null
170
178
171
179
Under **Available Debuggers**, select **New instance of \<your preferred Visual Studio version/edition>**, if not already selected.
172
180
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
+
173
184
1. Select **OK**.
174
185
175
186
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
181
192
> [!CAUTION]
182
193
> 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**.
0 commit comments