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-from-a-dll-project.md
+38-31
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
-
title: Debug a DLL Project from the project itself
3
-
description: You can start the debugging of a DLL project from the project itself, by specifying the calling app in the project properties. See this article for details.
4
-
ms.date: 4/21/2023
2
+
title: Debug a DLL Project from the Project Itself
3
+
description: Learn how to start debugging a DLL project from the project itself by specifying the calling application in the project properties.
4
+
ms.date: 04/18/2025
5
5
ms.topic: how-to
6
6
dev_langs:
7
7
- CSharp
@@ -17,96 +17,103 @@ author: mikejo5000
17
17
ms.author: mikejo
18
18
manager: mijacobs
19
19
ms.subservice: debug-diagnostics
20
+
#customer intent: As a developer, I want to debug a DLL project from the project itself in Visual Studio, so I can trigger debug actions from the calling application.
20
21
---
21
22
# Debug from a DLL project in Visual Studio (C#, C++, Visual Basic, F#)
22
23
23
-
One way to debug a DLL project is to specify the calling app in the DLL project properties. Then you can start debugging from the DLL project itself. For this method to work, the app must call the same DLL in the same location as the one you configure. If the app finds and loads a different version of the DLL, that version won't contain your breakpoints. For other methods of debugging DLLs, see [Debugging DLL projects](../debugger/debugging-dll-projects.md).
24
+
One way to debug a DLL project is to specify the calling app in the DLL project properties. This approach lets you start debugging from the DLL project itself. For this method to work, the app must call the same DLL in the same location as the one you configure. If the app finds and loads a different version of the DLL, that version doesn't contain your breakpoints. For other methods of debugging DLLs, see [Debugging DLL projects](../debugger/debugging-dll-projects.md).
24
25
25
26
If your managed app calls a native DLL, or your native app calls a managed DLL, you can debug both the DLL and the calling app. For more information, see [How to: Debug in mixed mode](../debugger/how-to-debug-in-mixed-mode.md).
26
27
27
28
Native and managed DLL projects have different settings to specify calling apps.
28
29
29
30
## Specify a calling app in a native DLL project
30
31
31
-
1.Select the C++ DLL project in **Solution Explorer**. Select the **Properties**icon, press **Alt**+**Enter**, or right-click and choose **Properties**.
32
+
1.In **Solution Explorer**, right-click the C++ DLL project and select **Properties**(**Alt**+**Enter**).
32
33
33
-
1. In the **\<Project> Property Pages** dialog box, make sure the **Configuration** field at the top of the window is set to **Debug**.
34
+
1. In the **\<Project> Property Pages** dialog, set the **Configuration** field at the top to **Debug**.
:::image type="content" source="../debugger/media/dbg-debugging-properties-dll.png" alt-text="Screenshot of the Debug Properties window in Visual Studio showing the value for the command." lightbox="../debugger/media/dbg-debugging-properties-dll.png":::
42
43
43
44
1. Add any necessary program arguments to the **Command Arguments** box.
44
45
45
46
1. Select **OK**.
46
47
47
48
::: moniker range=">= vs-2022"
48
-
## Specify a calling app in a C# DLL project (.NET Core, .NET 5+)
49
49
50
-
1. Select the C# or Visual Basic DLL project in **Solution Explorer**. Select the **Properties** icon, press **Alt**+**Enter**, or right-click and choose **Properties**.
50
+
## Specify a calling app in a managed DLL project (.NET Core, .NET 5+)
51
+
52
+
1. In **Solution Explorer**, right-click the C# or Visual Basic DLL project and select **Properties** (**Alt**+**Enter**).
51
53
52
54
1. In the Debug tab, select **Open Debug launch profiles UI**.
53
55
54
-
1. In the Launch Profiles dialog box, select the **Create a new profile** icon, and choose**Executable**.
56
+
1. In the **Launch Profiles** dialog, select the **Create a new profile** icon, and select**Executable**.
55
57
56
-
:::image type="content" source="../debugger/media/vs-2022/dbg-profile-create-new.png" alt-text="Screenshot of the UI to create a new debug profile.":::
58
+
:::image type="content" source="../debugger/media/vs-2022/dbg-profile-create-new.png" border="false" alt-text="Screenshot of the UI to create a new debug profile in Visual Studio 2022." lightbox="../debugger/media/vs-2022/dbg-profile-create-new.png":::
57
59
58
60
1. In the new profile, under **Executable**, browse to the location of the executable (*.exe* file) and select it.
59
61
60
-
1. In the Launch Profiles dialog box, note the name of the default profile, then select it and delete it.
62
+
1. In the **Launch Profiles** dialog, note the name of the default profile, then select the profile and delete it.
61
63
62
64
1. Rename the new profile to the same name as the default profile.
63
65
64
-
Alternatively, you can manually edit *launchSettings.json*to get the same result. You want the first profile in *launchSettings.json* to match the name of the Class Library, and you want it listed first in the file.
66
+
An alternate approach is to manually edit the *launchSettings.json*file. You want the first profile in the *launchSettings.json*file to match the name of the Class Library, and you want the profile listed first in the file.
65
67
66
68
::: moniker-end
67
69
68
-
## Specify a calling app in a managed DLL project
70
+
## Specify a calling app in a managed DLL project (.NET Framework)
69
71
70
-
1.Select the C# or Visual Basic DLL project in **Solution Explorer**. Select the **Properties**icon, press **Alt**+**Enter**, or right-click and choose **Properties**.
72
+
1.In **Solution Explorer**, right-click the C# or Visual Basic DLL project and select **Properties**(**Alt**+**Enter**).
71
73
72
-
1.Make sure that the **Configuration** field at the top of the window is set to **Debug**.
74
+
1.Set the **Configuration** field at the top to **Debug**.
73
75
74
76
1. Under **Start action**:
75
77
76
78
- For .NET Framework DLLs, select **Start external program**, and add the fully qualified path and name of the calling app.
77
79
78
-
- Or, select **Start browser with URL** and fill in the URL of a local ASP.NET app.
80
+
- Or, select **Start browser with URL** and enter the URL of a local ASP.NET app.
79
81
80
82
::: moniker range=">= vs-2022"
81
-
- For .NET Core DLLs in Visual Basic, the **Debug** Properties page is different. Select **Executable** from the **Launch** dropdown, and then add the fully qualified path and name of the calling app in the **Executable** field.
83
+
84
+
- For .NET Core DLLs in Visual Basic, the **Debug** Properties page is different. Expand the **Launch** dropdown and select **Executable**, and then add the fully qualified path and name of the calling app in the **Executable** field.
85
+
82
86
::: moniker-end
83
87
::: moniker range="<= vs-2019"
84
-
- For .NET Core DLLs, the **Debug** Properties page is different. Select **Executable** from the **Launch** dropdown, and then add the fully qualified path and name of the calling app in the **Executable** field.
88
+
89
+
- For .NET Core DLLs, the **Debug** Properties page is different. Expand the **Launch** dropdown and select **Executable**, and then add the fully qualified path and name of the calling app in the **Executable** field.
90
+
85
91
::: moniker-end
86
92
87
93
1. Add any necessary command-line arguments in the **Command line arguments** or **Application arguments** field.
:::image type="content" source="../debugger/media/dbg-debugging-properties-dll-csharp.png" border="false" alt-text="Screenshot of the C# Debug Properties window in Visual Studio." lightbox="../debugger/media/dbg-debugging-properties-dll-csharp.png":::
90
96
91
-
1.Use **File** > **Save Selected Items**or **Ctrl**+**S** to save changes.
97
+
1.To save your changes, select **File** > **Save Selected Items**(**Ctrl**+**S**).
92
98
93
99
## Debug from the DLL project
94
100
95
101
1. Set breakpoints in the DLL project.
96
102
97
-
1. Right-click the DLL project and choose**Set as Startup Project**.
103
+
1. Right-click the DLL project and select**Set as Startup Project**.
98
104
99
-
1.Make sure the **Solutions Configuration** field is set to **Debug**. Press**F5**, click the green **Start** arrow, or select **Debug** > **Start Debugging**.
105
+
1.Set the **Solutions Configuration** field at the top to **Debug**. Select**F5** and then select the green **Start** arrow, or select **Debug** > **Start Debugging**.
100
106
101
-
Additional tips:
102
-
103
-
- If debugging does not hit your breakpoints, make sure that your DLL output (by default, the *\<project>\Debug* folder) is the location that the calling app is calling.
104
-
105
-
- If you want to break into code in a managed calling app from a native DLL, or vice versa, enable [mixed mode debugging](../debugger/how-to-debug-in-mixed-mode.md).
106
-
107
-
- In some scenarios, you may need to tell the debugger where to find the source code. For more information, see [Use the No Symbols Loaded/No Source Loaded pages](../debugger/specify-symbol-dot-pdb-and-source-files-in-the-visual-studio-debugger.md#use-the-no-symbols-loadedno-source-loaded-pages).
107
+
> [!TIP]
108
+
>
109
+
> - If debugging doesn't hit your breakpoints, make sure your DLL output (by default, the *\<project>\Debug* folder) is the target call location for the calling app.
110
+
>
111
+
> - If you want to break into code in a managed calling app from a native DLL, or vice versa, enable [mixed mode debugging](../debugger/how-to-debug-in-mixed-mode.md).
112
+
>
113
+
> - In some scenarios, you might need to instruct the debugger where to find the source code. For more information, see [Use the No Symbols Loaded/No Source Loaded pages](../debugger/specify-symbol-dot-pdb-and-source-files-in-the-visual-studio-debugger.md#use-the-no-symbols-loadedno-source-loaded-pages).
0 commit comments