Skip to content

Commit 12d6398

Browse files
authored
Merge pull request #3147 from MicrosoftDocs/master
10/25 AM Publish
2 parents 97204b8 + 59d58c3 commit 12d6398

32 files changed

+383
-366
lines changed

docs/code-quality/C26403.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Owner pointers are like unique pointers: they own a resource exclusively, and ma
2121
For more information, see the [C++ Core Guidelines](http://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#r-resource-management).
2222

2323
## Remarks
24-
- Currently (Visual Studio 2017 version 15.3) this check doesn’t give the exact path which fails to release the resource. This behavior may be imporved in future releases. It may be difficult to find exact location for a fix. The better approach is to try to replace plain pointers in complex functions with unique pointers to avoid any risks.
24+
- Currently (Visual Studio 2017 version 15.3) this check doesn’t give the exact path which fails to release the resource. This behavior may be improved in future releases. It may be difficult to find exact location for a fix. The better approach is to try to replace plain pointers in complex functions with unique pointers to avoid any risks.
2525

2626
- The check may discard an over-complicated function in order to not block code analysis. Generally, the complexity of functions should be maintained under some reasonable threshold. We may consider adding a local complexity check to the C++ Core Guidelines module if there is clear demand for it. This limitation is applicable to other rules which are sensitive to data flow.
2727

@@ -44,4 +44,4 @@ catch (const std::exception& e)
4444
}
4545

4646
delete [] sequence;
47-
```
47+
```

docs/debugger/finding-memory-leaks-using-the-crt-library.md

Lines changed: 71 additions & 68 deletions
Large diffs are not rendered by default.

docs/debugger/how-to-debug-managed-and-native-code.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Tutorial: Debug managed and native code (mixed mode)"
33
description: Learn how to debug a native DLL from a .NET Core or .NET Framework app using mixed mode debugging
44
ms.custom: ""
5-
ms.date: "04/27/2018"
5+
ms.date: "10/24/2018"
66
ms.technology: "vs-ide-debug"
77
ms.topic: "tutorial"
88
dev_langs:
@@ -17,7 +17,7 @@ ms.workload:
1717
- "dotnet"
1818
- "cplusplus"
1919
---
20-
# Tutorial: Debug managed and native code in Visual Studio
20+
# Tutorial: Debug managed and native code in the same debugging session
2121

2222
Visual Studio allows you to enable more than one debugger type when debugging, which is called mixed mode debugging. In this tutorial, you set options to debug both managed and native code in a single debugging session. This tutorial shows how to debug native code from a managed app, but you can also do the reverse, and [debug managed code from a native app](../debugger/how-to-debug-in-mixed-mode.md). The debugger also supports other types of mixed mode debugging, such as debugging [Python and native code](../python/debugging-mixed-mode-c-cpp-python-in-visual-studio.md) and using the script debugger in app types such as ASP.NET.
2323

@@ -36,34 +36,34 @@ In this tutorial, you will:
3636

3737
If you haven't already installed Visual Studio, go to the [Visual Studio downloads](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=button+cta&utm_content=download+vs2017) page to install it for free.
3838

39-
If you need to install the workload but already have Visual Studio, click the **Open Visual Studio Installer** link in the left pane of the **New Project** dialog box. The Visual Studio Installer launches. Choose the **Node.js development** workload, then choose **Modify**.
39+
If you need to install the workload but already have Visual Studio, click the **Open Visual Studio Installer** link in the left pane of the **New Project** dialog box. The Visual Studio Installer launches. Choose the **Desktop development with C++** workload, then choose **Modify**.
4040

4141
* You must also have either the **.NET desktop development** workload or the **.NET Core cross platform development** workload installed, depending on which app type you want to create.
4242

4343
## Create a simple native DLL
4444

4545
1. In Visual Studio, choose **File** > **New** > **Project**.
4646

47-
1. In the **New Project** dialog box, choose **Visual C++**, **General** from the installed templates section, and then in the middle pane select **Empty Project**.
47+
1. In the **New Project** dialog box, choose **Visual C++**, **Other** from the installed templates section, and then in the middle pane select **Empty Project**.
4848

49-
1. In the **Name** field, type **Mixed-Mode-Debugging** and click **OK**.
49+
1. In the **Name** field, type **Mixed_Mode_Debugging** and click **OK**.
5050

5151
Visual Studio creates the empty project, which appears in Solution Explorer in the right pane.
5252

53-
1. In Solution Explorer, right-click the **Source Files** node in the C++ project, and then choose **Add** > **New Item**, and then select **C++ file (.cpp)**. Give the file the name **Mixed-Mode.cpp**, and choose **Add**.
53+
1. In Solution Explorer, right-click the **Source Files** node in the C++ project, and then choose **Add** > **New Item**, and then select **C++ file (.cpp)**. Give the file the name **Mixed_Mode.cpp**, and choose **Add**.
5454

5555
Visual Studio adds the new C++ file.
5656

57-
1. Copy the following code into *Mixed-Mode.cpp*:
57+
1. Copy the following code into *Mixed_Mode.cpp*:
5858

5959
```cpp
6060
#include "Mixed_Mode.h"
6161
```
62-
1. In Solution Explorer, right-click the **Header Files** node in the C++ project, and then choose **Add** > **New Item**, and then select **Header file (.h)**. Give the file the name **Mixed-Mode.h**, and choose **Add**.
62+
1. In Solution Explorer, right-click the **Header Files** node in the C++ project, and then choose **Add** > **New Item**, and then select **Header file (.h)**. Give the file the name **Mixed_Mode.h**, and choose **Add**.
6363

6464
Visual Studio adds the new header file.
6565

66-
1. Copy the following code into *Mixed-Mode.h*:
66+
1. Copy the following code into *Mixed_Mode.h*:
6767

6868
```cpp
6969
#ifndef MIXED_MODE_MULTIPLY_HPP
@@ -78,27 +78,30 @@ In this tutorial, you will:
7878
#endif
7979
```
8080

81-
1. From the Debug toolbar, select a **Debug** configuration and **Any CPU** as the platform, or, for .NET Core, select **x64** as the platform.
81+
1. From the Debug toolbar, select a **Debug** configuration and **x86** or **x64** as the platform (for .NET Core, which always runs in 64-bit mode, select **x64** as the platform).
8282

83-
> [!NOTE]
84-
> On .NET Core, choose **x64** as the platform. .NET Core always runs in 64-bit mode so this is required.
83+
1. In Solution Explorer, right-click the project node (**Mixed_Mode_Debugging**) and choose **Properties**.
8584

86-
1. In Solution Explorer, right-click the project node (**Mixed-Mode-Debugging**) and choose **Properties**.
85+
> [!IMPORTANT]
86+
> Property configuration for C++ is per-platform. So, if you switch from one to the other (x86 to x64 or vice versa), you must also set the properties for the new configuration. (In the Properties page, verify either **x64** or **Win32** is set as the platform at the top of the page.)
8787
88-
1. In the **Properties** page, choose **Configuration Properties** > **Linker** > **Advanced**, and then in the **No Entry Point** drop-down list, select **NO**. Then apply settings.
88+
1. In the **Properties** page, choose **Configuration Properties** > **Linker** > **Advanced**, and then in the **No Entry Point** drop-down list, make sure that **No** is selected. If you need to change the setting to **No**, then choose **Apply**.
8989

9090
1. In the **Properties** page, choose **Configuration Properties** > **General**, and then select **Dynamic Library (.dll)** from the **Configuration Type** field. Then apply settings.
9191

9292
![Switch to a native DLL](../debugger/media/mixed-mode-set-as-native-dll.png)
9393

94-
1. Right-click the project and choose **Debug** > **Build**.
94+
1. Right-click the project and choose **Build**.
9595

9696
The project should build with no errors.
9797

9898
## Create a simple .NET Framework or .NET Core app to call the DLL
9999

100100
1. In Visual Studio, choose **File** > **New** > **Project**.
101101

102+
> [!NOTE]
103+
> Although you can also add the new managed project to the solution with the C++ project, instead of creating a new solution, we are not doing that here to support a larger set of debugging scenarios.
104+
102105
1. Choose a template for your application code.
103106

104107
For .NET Framework, in the **New Project** dialog box, choose **Visual C#**, **Windows Desktop** from the installed templates section, and then in the middle pane select **Console App (.NET Framework)**.
@@ -122,9 +125,9 @@ In this tutorial, you will:
122125
// Replace the file path shown here with the
123126
// file path on your computer. For .NET Core, the typical (default) path
124127
// for a 64-bit DLL might look like this:
125-
// C:\Users\username\source\repos\Mixed-Mode-Debugging\x64\Debug\Mixed-Mode-Debugging.dll
126-
// Here, we show a typical path for a DLL targeting the **Any CPU** option.
127-
[DllImport(@"C:\Users\username\source\repos\Mixed-Mode-Debugging\Debug\Mixed-Mode-Debugging.dll", EntryPoint =
128+
// C:\Users\username\source\repos\Mixed_Mode_Debugging\x64\Debug\Mixed_Mode_Debugging.dll
129+
// Here, we show a typical path for a DLL targeting the **x86** option.
130+
[DllImport(@"C:\Users\username\source\repos\Mixed_Mode_Debugging\Debug\Mixed_Mode_Debugging.dll", EntryPoint =
128131
"mixed_mode_multiply", CallingConvention = CallingConvention.StdCall)]
129132
public static extern int Multiply(int x, int y);
130133
public static void Main(string[] args)
@@ -137,6 +140,8 @@ In this tutorial, you will:
137140
}
138141
```
139142

143+
1. In the new code, update the file path to the path for the DLL that you previously created (see code comments). Make sure you replace the *username* placeholder.
144+
140145
## Configure mixed mode debugging (.NET Framework)
141146

142147
1. In Solution Explorer, right-click the managed **Mixed_Mode_Calling_App** project and choose **Set as Startup Project**.

0 commit comments

Comments
 (0)