Condividi tramite


How to: Debug in mixed mode (C#, C++, Visual Basic)

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

The following procedures describe how to enable debugging for managed and native code together, also known as mixed-mode debugging. There are two mixed-mode debugging scenarios:

  • The app that calls a DLL is written in native code, and the DLL is managed.

  • The app that calls a DLL is written in managed code, and the DLL is in native code. For a tutorial that walks you through this scenario in more detail, see Debug managed and native code.

You can enable both managed and native debuggers in the calling app project's Property pages. The settings differ between native and managed apps.

If you don't have access to a calling app's project, you can debug the DLL from the DLL project. You don't need mixed mode to debug just the DLL project. For more information, see How to: Debug from a DLL project.

Note

The dialog boxes and commands you see might differ from the ones in this article, depending on your Visual Studio settings or edition. To change your settings, choose Tools > Import and Export Settings. For more information, see Reset settings.

Enable mixed-mode debugging for a native calling app

  1. Select the C++ project in Solution Explorer and click the Properties icon, press Alt+Enter, or right-click and choose Properties.

  2. In the <Project> Property Pages dialog box, expand Configuration Properties, and then select Debugging.

  3. Set Debugger Type to Mixed or Auto.

  4. Select OK.

    Enable mixed mode debugging in C++

Enable mixed-mode debugging for a managed calling app

  1. Select the C# or Visual Basic project in Solution Explorer and select the Properties icon, press Alt+Enter, or right-click and choose Properties.

  2. In Solution Explorer, select the C# or Visual Basic project node and select the Properties icon, or right-click the project node and select Properties.

  3. Enable native code debugging in the properties.

See also