开发者

How do I debug a native code project from inside a managed code project? C++/C#

How do I debug a native code project from inside a managed code project? I am using C# to call C++ code and need to debug the C++ code. O开发者_StackOverflow中文版therwise, I must exit out of the project, open the C++ project, create a tester and then debug the code. This is horrible.


Add your c++ project to the solution containing your C# code

In the C# project properties pages, under the debug tab

Check "Enable unmanaged code debugging"

If that doesn't work you also need to open the Options dialog from either the Debug or the Tools menu (in VS2017) and go to Debugging->General. Check the option

"Suppress JIT optimization on module load (Managed only)."

You will then be able to debug into your C++/CLI and C++ code. (This final tip comes from Kim Togo Andersen.)


In the debugging options for visual studio you HAVE to specify the correct debugger type.

Open up the property dialog window for the project, and under the Configuration Properties select Debugging. For the Debugger Type option, select the property that applies:

This can be auto, or mixed. I prefer mixed as it is explicitly stating you want both managed and native debugging.

As a side note, you can pick native only, but you won't be able to set a breakpoint in managed code. I'm not sure if this is an issue for you or not.

If you pick managed only, you obviously won't hit any breakpoints in native code.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜