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

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 all 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.

    For C#, select Debug in the left pane, select Open debug launch profiles UI, then select the Enable native code debugging check box, and then close the properties page to save the changes. Enable mixed mode debugging in C#

    For Visual Basic, select Debug in the left pane, select the Enable native code debugging check box, and then close the properties page to save the changes.

    Enable mixed mode debugging in Visual Basic

    Select Debug in the left pane, select the Enable native code debugging check box, and then close the properties page to save the changes.

    Enable mixed mode debugging

    Note

    For a .NET Core app in Visual Studio 2017 and Visual Studio 2019, you must use the launchSettings.json file instead of the project properties to enable mixed-mode debugging.