CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2005
    Location
    SJCampos - SP - Brazil
    Posts
    30

    Question What can be wrong that makes me unable to debug native C++ code?

    Hi. I have a mixed project (C++ Managed library) that uses managed and unmanaged code. I am having problems in debugging native (unmanaged) code. The breakpoints don’t work (when I put one in the native code, appears a “?” ) and I can not give a “step into” for native codes. It is intriguing that some native codes debug works well, but for most of it, it doesn’t.

    This C++ library do not use others libraries, just native codes. It is used for a C# .Net application.

    I have changed the "debuger type" option from Mixed to Native Only, but this did not help. I have checked the Assembly files path already.

    What can be wrong that makes me unable to debug native C++ code?

    For Example:

    Code:
    void PDAManager::DefinirAltitudeParaPosicaoGeografica( SPosicaoGeografica __gc& p_posicaoGeografica ){
    
    	p_posicaoGeografica.Altitude = _PrjDG->pMne->ObterAltitude( p_posicaoGeografica.Latitude, p_posicaoGeografica.Longitude );
    
    }
    I can not go into "_PrjDG->pMne->ObterAltitude" even though this code is part of my project.
    Eliseu M. Gomes

    [email protected]

  2. #2
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: What can be wrong that makes me unable to debug native C++ code?

    There are known problems with mixed-mode debugging. I know from past experience how frustrating it can be : but that's about it I'm afraid, you'll have to live with it.

    I don't know if MS have fixed the problems in VC2005 though : it might be worth a look.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  3. #3
    Join Date
    Dec 2005
    Location
    SJCampos - SP - Brazil
    Posts
    30

    Unhappy Re: What can be wrong that makes me unable to debug native C++ code?

    Last edited by Eliseu_CEL; February 7th, 2006 at 03:44 PM. Reason: more links
    Eliseu M. Gomes

    [email protected]

  4. #4
    Join Date
    Dec 2005
    Location
    SJCampos - SP - Brazil
    Posts
    30

    Re: What can be wrong that makes me unable to debug native C++ code?

    I 've found the solution here:

    http://blogs.msdn.com/stevejs/archiv...05/126497.aspx

    C# and VB projects do not have a way to turn off managed debugging. If you want to native debug a application that starts from a managed exe, my suggestion is to leave the original project as managed only, and create an additional project to do your native debugging. The most versatile way is to create an empty VC++ makefile project. Right click on the solution, Add/ New Project/ Visual C++/Makefile Project. Right click on the new project Properties/Debugging/Debugger Type. There are 4 choices: “Native only”, ”Managed Only”, “Mixed”, and “Auto”. Use Native only. Never use Auto. A few rows up is “Command”, left click to get a dropdown with Internet Explorer, ActiveX container, regsvr32 and browse. Pick browse and find the .exe output of your current startup project. Finally in the top right of this property dialog is a button “Configuration Manager”. Click on it and you will see a list of the projects in the Solution with configuration, platform, and check box on whether it should build. Uncheck the build box for the makefile project you just created. At this point you can set the makefile project to be the startup project: Right click on the Project /Set as Startup Project. You will now launch in native debugging mode. You can either switch statup projects or switch the Debugger Type setting in the makefile project to switch back and forth. You can also detach when debugging this way and reattach with the other debugger type. This is typically more flexible, stable, and productive.
    and here:

    An easier way is to right-click on solution node, choose add project and then navigate to your exe and add it. .EXE is a recognized C++ project type. You still have to follow the steps mentioned above. Of course, you do need C++ installed as part of your VS setup.
    Eliseu M. Gomes

    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured