.net - Automatically break debugger on Debug.Assert fail
问题描述
This may seem like a silly question, but no amount of Googling will give me the answer. In C#, when using the Debug.Assert
class, a failure causes a MessageBox to show. Pressing "Retry" goes to the call site in the debugger. Is there any way to do so automatically i.e. go straight to the call site (skip pressing "Retry" every time?)
解决方案
用于System.Diagnostics.Debugger.Break();
暂停进程的执行,就像遇到调试器断点一样:
void DebugAssert(bool condition)
{
if(!condition)
System.Diagnostics.Debugger.Break();
}
推荐阅读
- ssl - 找不到 BizTalk WCF-WebHttp 适配器客户端证书
- python - 如何在使用 python 脚本保留格式的同时编辑 yaml 文件?
- c - 如何在printk中使用变量作为格式字符串?
- php - 引导表无法识别使用 AJAX 生成的行
- chilkat - 协议 SFTP 和 TLS 1.2 握手,发送文件
- vhdl - 在不编辑分配的情况下获取矢量端口的两个末端
- c# - QPID 和 AmqNetLite 的连接错误 SASL 错误
- ios - 计算 2 个日期选择器之间的天数
- neo4j - 如何克隆节点的子树,最简单和最快的方法是什么?
- powerpoint - 在浏览器中渲染 PPTX (2018)