Debugger.Break Debugger.Break Debugger.Break Debugger.Break Method

定義

表示已附加偵錯工具的中斷點。Signals a breakpoint to an attached debugger.

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

例外狀況

UIPermission 未設定要中斷偵錯工具。The UIPermission is not set to break into the debugger.

範例

下列程式碼範例示範如何停止偵錯工具在呼叫WriteLineThe following code example demonstrates how to stop the debugger at the call to WriteLine.

Debugger.Break()  
Console.WriteLine("Hello, world.")  
Debugger.Break();  
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.

安全性

UIPermission
若要啟動偵錯工具的權限。for permission to start a debugger. 相關聯的列舉型別: UnrestrictedAssociated enumeration: Unrestricted

SecurityPermission
操作與 unmanaged 程式碼。for operating with unmanaged code. 相關聯的列舉型別:UnmanagedCode 安全性動作: DemandAssociated enumeration: UnmanagedCode Security action: Demand.

適用於