以纯原生模式在C#启动项目上启动调试 [英] Start debugging on C# startup project in native-only mode

查看:145
本文介绍了以纯原生模式在C#启动项目上启动调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MSVC2013解决方案与C#(托管)和C + +(本地)项目。一个 C#项目已设置为启动项目。我想使用调试启动这个项目,这通常是在devenv中通过简单地按F5实现。

I have a MSVC2013 solution with C# (managed) and C++ (native) projects. One C# project is set as startup project. I want to start this project with debugging, which is usually achieved in devenv by simply pressing F5.

但是,我想在 native-only 模式(即无托管调试)。我不能通过更改C#项目的设置实现这种行为:它只有一个选项启用本机代码调试,允许启用或禁用本机调试。我知道的唯一标准的方法是启动应用程序而不调试,然后附加到进程只选择本地调试。

However, I want to start debugger in native-only mode (i.e. no managed debugging). I cannot achieve this behavior by changing settings of C# project: it only has an option "Enable native code debugging", which allows to enable or disable native debugging. The only standard way I know is to start application without debugging, and then attach to process with only native debugging chosen.

有没有办法自动化这个过程?理想情况下,按下一个按钮应该足以启动native-only调试。

Is there a way to automate this process? Ideally, pressing one button should be enough to start native-only debugging. Perhaps some extension could simplify this task.

我已经碰到一个讨厌的错误混合模式调试,在我的情况下打破调试完全。这个bug本身是不是问题的主题,它只是解释为什么使用C#启动项目的本机调试可能是有用的(对我个人有用)。

P.S. I have bumped into a nasty bug in mixed mode debugging, which breaks debugging completely in my case. This bug itself is not the topic of the question, it just explains why native-only debugging with C# startup project may be useful (and is useful to me personally).

推荐答案

这不是很清楚为什么你不能简单地使用项目>属性>调试选项卡>勾选启用本机代码调试。如果你使用VS2012及以上,请小心你必须禁用新的托管调试引擎,它不再与C ++ / CLI代码兼容。使用工具>选项>调试>常规>勾选使用托管兼容模式。

It is not very clear why you can't simply use Project > Properties > Debug tab > tick "Enable native code debugging". If you use VS2012 and up then do beware that you have to disable the new managed debugging engine, it is no longer compatible with C++/CLI code. Use Tools > Options > Debugging > General > tick "Use Managed Compatibility Mode".

但是你可以实现你想要的,只需选择一个本地代码项目作为你的启动项目。右键单击>设置为启动项目。并且必须选择启动EXE,右键单击>属性>调试>命令,将其更改为C#可执行文件。 C#代码加载您的DLL后,断点变为活动状态(颜色为红色)。

But you can achieve what you want, simply select one of the native code projects as your startup project. Right-click > Set as Startup Project. And you must select the startup EXE, Right-click > Properties > Debugging > Command, change it to the C# executable. Breakpoints become active (colored solid red) as soon as the C# code loads your DLL.

这篇关于以纯原生模式在C#启动项目上启动调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆