Debugger.Break 方法


发出信号表示连接调试器的断点。Signals a breakpoint to an attached debugger.

 static void Break();
public static void Break ();
static member Break : unit -> unit
Public Shared Sub Break ()


未设置跳转到调试器所需的 UIPermissionThe UIPermission is not set to break into the debugger.


下面的代码示例演示如何在调用 WriteLine时停止调试器。The following code example demonstrates how to stop the debugger at the call to WriteLine.

Console.WriteLine("Hello, world.")  
Console.WriteLine("Hello, world.");  


如果未附加任何调试器,则会询问用户是否要附加调试器。If no debugger is attached, users are asked if they want to attach a debugger. 如果用户为 "是",则启动调试器。If users say yes, the debugger is started. 如果附加了调试器,则调试器将使用用户断点事件发出信号,并且调试器会挂起进程的执行,就像已命中调试器断点一样。If a debugger is attached, the debugger is signaled with a user breakpoint event, and the debugger suspends execution of the process just as if a debugger breakpoint had been hit.


.NET Framework 4.NET Framework 4开始,运行时将不再对为 Break 方法启动调试器进行严格控制,而是将错误报告到 Windows 错误报告(WER)子系统。Starting with .NET Framework 4.NET Framework 4, the runtime no longer exercises tight control of launching the debugger for the Break method, but instead reports an error to the Windows Error Reporting (WER) subsystem. WER 提供很多用于自定义问题报告体验的设置,因此,许多因素将影响 WER 响应错误的方式,如操作系统版本、进程、会话、用户、计算机和域。WER provides many settings to customize the problem reporting experience, so a lot of factors will influence the way WER responds to an error such as operating system version, process, session, user, machine and domain. 如果在调用 Break 方法时遇到意外的结果,请检查计算机上的 WER 设置。If you're having unexpected results when calling the Break method, check the WER settings on your machine. 有关如何自定义 WER 的详细信息,请参阅Wer 设置For more information on how to customize WER, see WER Settings. 如果要确保在启动调试器时不考虑 WER 设置,请确保改为调用 Launch 方法。If you want to ensure the debugger is launched regardless of the WER settings, be sure to call the Launch method instead.