none
Debug unmanaged code from C#

    Question

  • I have 3 projects:

    -one in C#
    -one in C++ managed (MC++)
    -one in C++ unmanaged (C++).

    (MC++) Wraps (C++) so it can be used by (C#).
    (MC++) and (C++) are compiled in a separate solution than (C#), so C# refers to (MC++) as an external assembly and (C++) Dll and PDB files are copied in the (C#) bin using a post build event.

    When debugging, I can trace into (C#) and (MC++) without no problem, but when trying to step into a function of (C++), it steps over it, so I cannot trace into (C++).

    All 3 projects have debugging information generation set on and I can see pdb files are being created:

    -The (C#) Debug info setting is set to "Full".
    -The (MC++) Debug Information Format is set to "Program Database (/Zi)" and GenerateDebug Info is set to "Yes (/DEBUG)"
    -The (C++) Debug Information Format is set to "Program Database (/Zi)" and GenerateDebug Info is set to "Yes (/DEBUG)"

    I also tried the Debuggable Assembly setting to "Runtime tracking and disable optimizations (/ASSEMBLYDEBUG)" on both (MC++) and (C++). 
    I also turned on "Enable unmanaged code debugging" on in (C#).

    What am I missing? Is there a way for me to be able to trace in (C++)?

    -Sylvain
    Thursday, June 26, 2008 4:32 PM

Answers

  • Under Tools.Options dialog, select the Debugging category, and make sure the "Enable Just My Code" setting is unchecked. 
    From the Project properties, select the Debug tab, and then ensure that "Enable unmanaged code debugging" is checked.

    Once you've got these squared away, you should get the mixed mode debugging support working.

    Also, if you use "Debug.Attach To Process" , be sure to hit the "Select..." button in the "Attach To Process" dialog, and select both Managed and Native debugging support.

    Sincerely,


    Ed Dore
    Thursday, June 26, 2008 7:41 PM
    Moderator

All replies

  • Under Tools.Options dialog, select the Debugging category, and make sure the "Enable Just My Code" setting is unchecked. 
    From the Project properties, select the Debug tab, and then ensure that "Enable unmanaged code debugging" is checked.

    Once you've got these squared away, you should get the mixed mode debugging support working.

    Also, if you use "Debug.Attach To Process" , be sure to hit the "Select..." button in the "Attach To Process" dialog, and select both Managed and Native debugging support.

    Sincerely,


    Ed Dore
    Thursday, June 26, 2008 7:41 PM
    Moderator
  • Ed Dore, You are my new God.

    Thank you so much.

    I also noticed "Enable Unmanaged Code Debugging" has to be activated on the StartUp Project that is used for debugging, not on the project using the unmanaged code.


    -Sylvain
    • Edited by Sylvain Boissé Thursday, June 26, 2008 9:34 PM Added comment about startup project.
    Thursday, June 26, 2008 9:30 PM
  • I tried these suggestions and still couldn't step into unmanaged code until I noticed that the .PDB file was out of date, and updated it.  (The framework really should give warnings when these problems occur, instead of silently malfunctioning, collectively wasting man-years among the user community.  Microsoft...)
    Monday, September 28, 2009 8:07 PM
  • Hello Ed Dore,

     

    I am facing similar problem as stated by Sylvain. Could you please guide me? Do I need to do Debug.Attach to process step?

     

    Thnaks in advance.

    Thursday, June 10, 2010 9:13 AM