有没有更好的方式让视觉工作室忽略try / catch在调试模式 [英] Is there a better way to get visual studio to ignore try/catch in debug mode

查看:144
本文介绍了有没有更好的方式让视觉工作室忽略try / catch在调试模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让设计师在调试时捕获错误,如果发生错误,我希望用户看到我的友好消息。我知道我可以用以下方式来解决这个问题:

 #如果调试= False然后

尝试

#End如果

'这里的一些代码

#If Debug = False然后

捕获ex作为异常

Messagebox.Show(Errors suck)

结束尝试

#End如果

我不想写所有的#statements,让他们混乱我的代码。似乎这应该是一个常见的需要,而且必须有一个更好的方法。有没有人知道更好的方法?

解决方案

在VS.NET中,您可以说是否要让调试器在异常抛出(不只是在未被处理的时候)。



查看Debug |例外...菜单项(Ctl-Alt-E在我的键盘快捷键上)。选择您感兴趣的小程序,然后勾选该异常的抛出框。



您可以在多个级别勾选该框(所有CLR异常,所有CLR给定命名空间中的异常,或非常具体的异常)


I want the designer to catch the error when I am debugging and I want the user to see my friendly message if an error occurs for them. I know I can acomplish this with the following:

#If Debug=False Then

Try

#End If

'some code here

#If Debug=False Then

Catch ex as exception

    Messagebox.Show("Errors suck")

End Try

#End If

I do not want to have to write all the #statements and having them cluttering up my code. It seems like this should be a common need and there has to be a better way. Does anyone know a better way?

解决方案

In VS.NET you can say whether you want the debugger to break when an exception is thrown (not just when it's unhandled).

Look on the Debug | Exceptions... menu item (Ctl-Alt-E on my keyboard shortcuts). Pick the excepption you're interested in, then tick the "thrown" box for that exception.

You can tick that box at several levels (all CLR exceptions, all CLR exceptions in a given namespace, or very specific exceptions)

这篇关于有没有更好的方式让视觉工作室忽略try / catch在调试模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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