Share via


How to: Debug in Mixed Mode

This topic applies to:

Edition

Visual Basic

C#

C++

Web Developer

Express

Topic does not apply Topic does not apply Topic applies Topic does not apply

Standard

Topic does not apply

Topic does not apply

Topic applies

Topic does not apply

Pro and Team

Topic does not apply

Topic does not apply

Topic applies

Topic does not apply

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.

The following procedures describe how to debug both managed and native code, also known as mixed-mode debugging. There are two scenarios for doing so, depending on whether the DLL or the application is written in native code:

  • The calling application that calls your DLL is written in native code. In this case your DLL is managed, and both managed and native debuggers must be enabled to debug both. You can check this in the <Project> Property Pages dialog box. How you do this depends on whether you start debugging from the DLL project or the calling application project.

  • The calling application that calls your DLL is written in managed code and your DLL is written in native code.

Note

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, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To enable mixed-mode debugging in a native EXE calling a managed DLL

  1. In Solution Explorer, select the project.

  2. On the View menu, click Property Pages.

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

  4. Set Debugger Type to Mixed or Auto.

To enable mixed-mode debugging in a managed EXE calling a native DLL

  1. In Solution Explorer, select the project.

  2. On the View menu, click Property Pages.

  3. In the Properties Pages, click the Debug tab.

  4. Under the Enable Debuggers group, select the Enable unmanaged code debugging check box.

    Note

    For the debugger to attach to code written in C++, the code needs to emit DebuggableAttribute. You can add this to your code automatically by linking with the /ASSEMBLYDEBUG (Add DebuggableAttribute) linker option.

See Also

Tasks

How to: Debug from a DLL Project