vb.net - 测试代码是否在 Debug模式下执行

标签 vb.net debugging

我如何测试代码在 Debug模式下执行。

这是我想用伪代码做的事情

if not debugMode then
  Do something()
end if

最佳答案

您可以使用 Debugger.IsAttached判断程序是否正在调试。

If Not Debugger.IsAttached Then
  DoSomething()
End If

编辑如果你总是想跳过 DoSomething调试版本中的代码,无论是否使用调试器,都使用 conditional compilation#If ,像这样
#IF DEBUG Then
  DoSomething()
#End If

关于vb.net - 测试代码是否在 Debug模式下执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1265581/

相关文章:

Perl -d 和 modulino 问题

asp.net - 如何突出显示 Gridview 中的最大值

.net - Thread.Sleep 是否会停用 TCPListener?

vb.net - VB.NET 属性中的括号

android - 在eclipse中运行而不调试

java - 在 Eclipse 中调试时重新加载 java 类

asp.net - 带有 SQL 数据源的 Gridview 正在删除空格

vb.net - VB 模块中的公共(public)属性 - 跨客户端行为

python - debug 变量传递给 python 解释器?

asp.net-mvc - ASP.NET MVC 2 发行版的实际调试符号