开发者

Debug Managed and Unmanaged code together

My main startup project is in c++. the solution involves also managed c# code. When I debug - I have breakpoints only on the unmanaged sections (on managed bre开发者_StackOverflow中文版akpoint it states : "The breakpoint will not currently be hit. invalid file line "

I checked the reference and saw that there is dll and pdb there.

What could it be?


how to set mixed-mode debugging http://msdn.microsoft.com/en-us/library/kbaht4dh(v=vs.100).aspx

And don't miss the link in the bottom.


If, like me, you are trying to debug a C++/CLI from a native C++ project (i.e. you've set /CLR on a single file), and it never hits breakpoints and can't be stepped into. Well my friends, in VS2015 go to

Tools->Options->Debugging->General

and tick the little box that says:

Enable .NET Framework source stepping

I believe you also need to set it to mixed-mode debugging ala the answers above, but that alone was not enough for me. With that box ticked I can go "step into" from my unmanaged C++ into managed code... there is a crazy amount of technology going on under the hood here...


You have to enable mixed-mode debugging. I can't recall where that is, offhand.


I have had many issues with mixed mode debugging. Indeed, some programs get instable (Excel interop mainly for me), and you cannot Edit and Continue any more.

One good way to debug managed and unmanaged mode at the same time is to setup a new dummy project, which will attach a unmanaged debugger to your application. You can debug the managed code with your old project, detach it and attach the native debugger when you want to debug the native code. This way, you also have edit and continue for both codes.

Instructions on setting this up are there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜