I have the following three projects in my solution: 1. C# library 2. C++/CLI managed code 3. C++ unmanaged code
I d开发者_JS百科id check "Enable Unmanaged Code Debugging" in my C# project, and built both C++ projects in Debug/Win32. However, I cannot step into unmanaged code - when I F11 on the call of any unmanaged method, it shows me some random/wrong code then exits.
Because my unit tests pass, I know that my unmanaged code does execute.
What am I missing?
When I've had this problem it has come from one of these things:
1) Enable unmanaged code debugging not checked. You already fixed this.
2) Built the EXE as x64 or Any CPU (they say x64 works, but it doesn't). I think you already fixed this.
3) "Just my code" being turned on sometimes causes trouble with unmanaged code debugging (Tools, Options, Debugger, Just My Code)
4) Incorrect debug options in the C++ project settings
5) Missing, corrupted or mismatched PDB files. You can check for this by trying to set a breakpoint in your C++ code while running in the debugger. If the breakpoint turns into a hollow circle, something is wrong with your debug info. Also check your output window as you run in debug mode -- it should tell you whose symbols got loaded.
I've seen this issue going the "other" way from time to time (ie, from native C++ to C++/CLI) and it's usually caused by the debugger not really picking up that it's supposed to debug both native and managed code.
Usually for me, setting the Debugger Type in Configuration Properties -> Debugging in your startup project from 'Auto' to 'Mixed' solves the problem.
精彩评论