VS2010(Express)调试器在控制台应用程序中捕获Ctrl + C [英] VS2010 (Express) debugger trapping Ctrl+C in Console app

查看:185
本文介绍了VS2010(Express)调试器在控制台应用程序中捕获Ctrl + C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


答案摘要



为避免调试器陷入Ctrl + C,首先关闭Visual Studio
主机进程(在项目属性Debug选项卡中找到)



如果您使用的是Visual Studio的Express版本,那么您可以执行
。如果您使用的是Pro或更好版本的Visual Studio,您可以
另外打开Debug> Exceptions ...,Win32 Exceptions,并取消选中
Ctrl + C。



作为替代方案,您可以在调试时使用Ctrl + Break,除非像我这样Ctrl + C硬连线到大脑中。 / p>

原始



。汉斯似乎已经撤回了他的答案,但是他的质询帮助我缩小了问题的陈述:



Extra Clarity




  • 我不想修改Ctrl + C的行为。

  • 我不是在寻找一个工作

  • 在调试会话期间按Ctrl + C时,我只想让调试器断开



请注意,以下示例被设计。只是为了证明这个行为。我改变了ReadKey行,因为它让人分心。



调试(运行)以下程序:

  class Program 
{
static void Main()
{
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
}
}

按Ctrl + C。调试器将会在休眠线上设置断点。



您如何关闭?我不希望调试器根据Ctrl + C中断。



这不会在家里与VS2008 Pro。



我现在已经尝试了VS2008 Express和VS2010 Express(唯一的版本,我可以很容易测试),他们都这样做。这导致我相信这是一个快照行为,或者有一个设置可以打开/关闭。


  1. 是有一个设置可以在任何版本/版本中打开/关闭?

  2. 此设置是否存在于VS2008,VS2010或两者中?

  3. 是在Express版本中暴露的设置?

  4. 我的VS2008 Pro的实例是否独一无二?是设置在旧版本的Visual Studio中暴露的东西(已经通过许多新版本继承了VS设置)。


解决方案

我找到答案,这是一个调试异常选项。我不知道我第一次错过了什么,但这里是:



调试 - >异常... Win32异常 - Control-C



这是在VS2008 Pro。



我也可以确认该选项存在于快递版本(整个Win32异常节点丢失)。



所以我剩下的唯一问题是,因为我不拥有VS2010 Pro(还有)呢? VS2010 Pro版本中是否存在Win32异常节点和Control-C异常?


Summary of Answers

To avoid the debugger trapping Ctrl+C first turn off the Visual Studio Hosting Process (found in project properties, Debug tab)

If you're using the Express version of Visual Studio, that's all you can do.

If you're using the Pro or better version of Visual Studio you can additionally open Debug > Exceptions..., Win32 Exceptions, and uncheck Ctrl+C.

As as alternative, you can use Ctrl+Break when debugging, unless like me Ctrl+C is hard-wired into your brain.

Original

The following has been edited. Hans seems to have retracted his answer, but his questioning has helped me to narrow down the problem statement:

Extra Clarity

  • I do not want to modify the behavior of Ctrl+C.
  • I'm not looking for a work around.
  • I simply want the debugger to NOT break when Ctrl+C is pressed during a debugging session.

Please note that the following example is contrived. It's just to demonstrate the behavior. I changed the ReadKey line as it was distracting people.

Debug (run) the following program:

class Program
{
    static void Main()
    {
        System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
    }
}

Press Ctrl+C. The debugger will break as if you set a breakpoint on the Sleep line.

How do you turn this off? I don't want the debugger to break at all for Ctrl+C.

This doesn't happen at home with VS2008 Pro.

I have now tried it with both VS2008 Express and VS2010 Express (the only editions I can test it with easily) and they all do it. This has led me to believe that either it's an Express behavior, or that there is a setting somewhere to toggle it on/off.

  1. Is there a setting to turn this on/off in any version/edition?
  2. Does this setting exist in VS2008, VS2010, or both?
  3. Is the setting exposed in the Express editions?
  4. Is my instance of VS2008 Pro unique? Is the setting something that was exposed in an old version of Visual Studio that has carried over (I have carried over VS settings through many new versions).

解决方案

I found the answer, it is a debugging Exception option. I don't know how I missed it the first time, but here it is:

Debug -> Exceptions... Win32 Exceptions - Control-C

This is in VS2008 Pro.

I can also confirm that the option does NOT exist in the Express editions (the entire Win32 Exceptions node is missing).

So the only question I have left, since I don't own VS2010 Pro (yet?) is: Does the Win32 Exceptions node, and the Control-C exception exist in the VS2010 Pro edition?

这篇关于VS2010(Express)调试器在控制台应用程序中捕获Ctrl + C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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