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/how-to-debug-managed-and-native-code.md
+14-2Lines changed: 14 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Tutorial: Debug C# and C++ code (mixed mode)"
3
3
description: Debug a native DLL from a .NET Core or .NET Framework application by using mixed-mode debugging to enable more than one debugger type in a debugging session.
4
-
ms.date: 09/18/2024
4
+
ms.date: 04/07/2025
5
5
ms.topic: tutorial
6
6
dev_langs:
7
7
- "CSharp"
@@ -54,7 +54,13 @@ If you have Visual Studio installed, but don't have the workloads you need, sele
54
54
55
55
1. Open Visual Studio and create a project.
56
56
57
+
::: moniker range=">=vs-2022"
58
+
Press **Esc** to close the start window. Type **Ctrl + Q** to open the search box, type **Empty Project**, and then select the **Empty Project** for C++. In the **Configure your new project** dialog box that appears, type a name like **Mixed_Mode_Debugging** and click **Create**.
59
+
::: moniker-end
60
+
61
+
::: moniker range="vs-2019"
57
62
Press **Esc** to close the start window. Type **Ctrl + Q** to open the search box, type **Empty Project**, choose **Templates**, then choose **Empty Project** for C++. In the dialog box that appears, choose **Create**. Then, type a name like **Mixed_Mode_Debugging** and click **Create**.
63
+
::: moniker-end
58
64
59
65
If you don't see the **Empty Project** project template, go to **Tools** > **Get Tools and Features...**, which opens the Visual Studio Installer. The Visual Studio Installer launches. Choose the **Desktop development with C++** workload, then choose **Modify**.
60
66
@@ -124,11 +130,17 @@ If you have Visual Studio installed, but don't have the workloads you need, sele
124
130
125
131
1. Open Visual Studio and create a new project.
126
132
133
+
::: moniker range=">=vs-2022"
134
+
Press **Esc** to close the start window. Type **Ctrl + Q** to open the search box, type **console**, and then select the C# **Console App** for .NET or .NET Framework.
135
+
::: moniker-end
136
+
137
+
::: moniker range="vs-2019"
127
138
Press **Esc** to close the start window. Type **Ctrl + Q** to open the search box, type **console**, choose **Templates**, and then choose **Console App** for .NET Core or **Console App (.NET Framework)** for C#. In the dialog box that appears, choose **Next**.
139
+
::: moniker-end
128
140
129
141
Then, type a name like **Mixed_Mode_Calling_App** and click **Next** or **Create**, whichever option is available.
130
142
131
-
For .NET Core, choose either the recommended target framework or .NET 8, and then choose **Create**.
143
+
For .NET Core or .NET 5+, choose either the recommended target framework or .NET 8, and then choose **Create**.
132
144
133
145
If you don't see the correct project template, go to **Tools** > **Get Tools and Features...**, which opens the Visual Studio Installer. Choose the correct .NET workload as described in the prerequisites, and then choose **Modify**.
Copy file name to clipboardExpand all lines: docs/debugger/quickstart-debug-with-cplusplus.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Debug C++ code, set breakpoints, inspect variables
3
3
description: Debug native C++ code by using the Visual Studio debugger, create a project, set breakpoints, inspect variables, and edit code while debugging.
4
-
ms.date: 08/06/2018
4
+
ms.date: 04/07/2025
5
5
ms.topic: quickstart
6
6
helpviewer_keywords:
7
7
- "debugger"
@@ -18,7 +18,7 @@ The Visual Studio debugger provides many powerful features to help you debug you
18
18
19
19
1. Open Visual Studio and create a project.
20
20
21
-
On the Welcome Page, select **Create a new project**. Select **Empty Project**. Make sure you are selecting the Project Template for C++.
21
+
If the Start window isn't already open, select **File > Start Window**. In the Start window, select **Create a new project**. In the search box, type "Empty project", and then select the C++**Empty Project** template.
22
22
23
23
If you don't see the project template, open the **Visual Studio Installer**. Choose the **Desktop development with C++ workload**, then choose **Modify**.
24
24
@@ -35,7 +35,7 @@ The Visual Studio debugger provides many powerful features to help you debug you
35
35
}
36
36
```
37
37
38
-
with this code (do not remove `#include "stdafx.h"`):
38
+
with this code (don't remove `#include "stdafx.h"`):
39
39
40
40
```cpp
41
41
#include <list>
@@ -66,7 +66,7 @@ The Visual Studio debugger provides many powerful features to help you debug you
66
66
67
67
## Set a breakpoint
68
68
69
-
A *breakpoint* is a marker that indicates where Visual Studio should suspend your running code so you can take a look at the values of variables, or the behavior of memory, or whether or not a branch of code is getting run. It is the most basic feature in debugging.
69
+
A *breakpoint* is a marker that indicates where Visual Studio should suspend your running code so you can take a look at the values of variables, or the behavior of memory, or whether or not a branch of code is getting run. It's the most basic feature in debugging.
70
70
71
71
1. To set the breakpoint, click in the gutter to the left of the `doWork` function call (or select the line of code and press **F9**).
72
72
@@ -76,7 +76,7 @@ A *breakpoint* is a marker that indicates where Visual Studio should suspend you
76
76
77
77

78
78
79
-
The debugger pauses where you set the breakpoint. The statement where the debugger and app execution is paused is indicated by the yellow arrow. The line with the `doWork` function call has not yet executed.
79
+
The debugger pauses where you set the breakpoint. The statement where the debugger and app execution is paused is indicated by the yellow arrow. The line with the `doWork` function call hasn't yet executed.
80
80
81
81
> [!TIP]
82
82
> If you have a breakpoint in a loop or recursion, or if you have many breakpoints that you frequently step through, use a [conditional breakpoint](../debugger/using-breakpoints.md#BKMK_Specify_a_breakpoint_condition_using_a_code_expression) to make sure that your code is suspended ONLY when specific conditions are met. A conditional breakpoint saves time and can also make it easier to debug issues that are hard to reproduce.
> Starting with Visual Studio 2022 version 17.9, visualizers can now be written in .NET 6.0+ that run out-of-process using the new VisualStudio.Extensibility model. We encourage visualizer authors to reference the new documentation at [Create Visual Studio debugger visualizers](../extensibility/visualstudio.extensibility/debugger-visualizer/debugger-visualizers.md) unless they want to support older versions of Visual Studio or want to ship their custom visualizers as part of a library DLL.
23
23
24
-
This walkthrough shows how to write a simple visualizer by using Visual Basic. The visualizer you will create in this walkthrough displays the contents of a string using a Windows Forms message box. This simple string visualizer is a basic example to show how you can create visualizers for other data types more applicable to your projects.
24
+
This walkthrough shows how to write a simple visualizer by using Visual Basic. The visualizer you'll create in this walkthrough displays the contents of a string using a Windows Forms message box. This simple string visualizer is a basic example to show how you can create visualizers for other data types more applicable to your projects.
25
25
26
26
> [!NOTE]
27
27
> The dialog boxes and menu commands you see might differ from those described in Help, depending on your active settings or edition. To change your settings, go to the **Tools** menu and choose **Import and Export** . For more information, see [Reset settings](../ide/personalizing-the-visual-studio-ide.md#reset-all-settings).
@@ -34,7 +34,13 @@ Visualizer code must be placed in a DLL that will be read by the debugger. The f
34
34
35
35
1. Create a new class library project.
36
36
37
-
Press **Esc** to close the start window. Type **Ctrl + Q** to open the search box, type **visual basic**, choose **Templates**, then choose **Create a new Class Library (.NET Framework)**. In the dialog box that appears, choose **Create**.
37
+
::: moniker range=">=vs-2022"
38
+
Press **Esc** to close the start window. Type **Ctrl + Q** to open the search box, type **class library**, and then select the Visual Basic **Class Library (.NET Framework)**.
39
+
::: moniker-end
40
+
41
+
::: moniker range="vs-2019"
42
+
Press **Esc** to close the start window. Type **Ctrl + Q** to open the search box, type **visual basic**, choose **Templates**, then choose **Create a new Class Library (.NET Framework)**.
43
+
::: moniker-end
38
44
39
45
2. Type an appropriate name for the class library, such as `MyFirstVisualizer`, and then click **Create** or **OK**.
40
46
@@ -64,7 +70,7 @@ Visualizer code must be placed in a DLL that will be read by the debugger. The f
64
70
```
65
71
66
72
## Add the Debugger-side Code
67
-
Now, you are ready to create the debugger-side code. This is the code that runs within the debugger to display the information that you want to visualize. First, you have to change the declaration of the `DebuggerSide` object so that it inherits from the base class `DialogDebuggerVisualizer`.
73
+
Now, you're ready to create the debugger-side code. This is the code that runs within the debugger to display the information that you want to visualize. First, you have to change the declaration of the `DebuggerSide` object so that it inherits from the base class `DialogDebuggerVisualizer`.
68
74
69
75
### To inherit from DialogDebuggerVisualizer
70
76
@@ -96,7 +102,7 @@ Visualizer code must be placed in a DLL that will be read by the debugger. The f
96
102
EndSub
97
103
```
98
104
99
-
The `Show` method contains the code that actually creates the visualizer dialog box, or other user interface, and displays the information that has been passed to the visualizer from the debugger. You must add the code that creates the dialog box and displays the information. In this walkthrough, you will do this using a Windows Forms message box. First, you must add a reference and `Imports` statement for <xref:System.Windows.Forms>.
105
+
The `Show` method contains the code that actually creates the visualizer dialog box, or other user interface, and displays the information that has been passed to the visualizer from the debugger. You must add the code that creates the dialog box and displays the information. In this walkthrough, you'll do this using a Windows Forms message box. First, you must add a reference and `Imports` statement for <xref:System.Windows.Forms>.
100
106
101
107
### To add System.Windows.Forms
102
108
@@ -115,7 +121,7 @@ Visualizer code must be placed in a DLL that will be read by the debugger. The f
Nowyou'll add some code to create and show the user interface for your visualizer. Because this is your first visualizer, you'll keep the user interface simple and use a Message Box.
119
125
120
126
###Toshowthevisualizeroutputinadialogbox
121
127
@@ -125,12 +131,12 @@ Visualizer code must be placed in a DLL that will be read by the debugger. The f
Thatistheendofthedebugger-sidecode.There's one more step, however: the attribute that tells the debuggee side which collection of classes comprises the visualizer.
134
140
135
141
###Toaddthetypetovisualizeforthedebuggee-sidecode
136
142
@@ -145,7 +151,7 @@ In the debugger-side code, you specify the type to visualize (the object source)
Atthispoint,yourfirstvisualizerisfinished.Ifyouhavefollowedthestepscorrectly,youcanbuildthevisualizerandinstallitintoVisualStudio.BeforeyouinstallavisualizerintoVisualStudio,however,youshouldtestittomakesurethatitrunscorrectly.you'll now create a test harness to run the visualizer without installing it into Visual Studio.
149
155
150
156
###Toaddatestmethodtoshowthevisualizer
151
157
@@ -187,7 +193,7 @@ In the debugger-side code, you specify the type to visualize (the object source)
187
193
6. Click **OK**.
188
194
189
195
## Finish Your Test Harness and Test Your Visualizer
190
-
Now, you will add the code to finish the test harness.
196
+
Now, you'll add the code to finish the test harness.
191
197
192
198
### To add code to MyTestConsole
193
199
@@ -210,7 +216,7 @@ In the debugger-side code, you specify the type to visualize (the object source)
0 commit comments