ser*_*hio 6 debugging visual-studio-2010 visual-studio
我测试异常拦截,所以,我不需要Visual Studio在thinkgs上打破thrown new NullReferenceException("myVar").
我在Debug => Exceptions下有以下内容

然而,VS打破例外.我该怎么办?
PS.
对于应用程序未处理的异常,我使用下面的Application.UnhandledExceptionas "捕获"它们:
''' <summary>Occurs when the application encounters an unhandled exception.</summary> '
Private Sub Application_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
Dim message As String = String.Format("An application UnhandledException were thrown.{1}The application will now terminate.{1}'{0}'{1}{1}StackTrace:{1}{2}", e.Exception.Message, Environment.NewLine, e.Exception.StackTrace)
MessageBox.Show(message)
End Sub
Run Code Online (Sandbox Code Playgroud)
小智 6
当我开始使用VS2010时,我遇到了同样的问题。我有单元测试,期望发生异常,并且从函数中抛出异常。这些异常应该由我的图书馆的用户处理。在“调试”->“异常”对话框中,我未选中“公共语言运行时异常”的“用户未处理”列下的复选框,并且VS停止破坏这些异常。顺便说一句,在您附加的对话框中,我看不到第二列。
如果您抛出一个未在代码中任何地方处理的异常,Visual Studio 将崩溃。它没有任何其他选择:存在未处理的异常。在 Visual Studio 之外,应用程序将显示错误消息并通知用户发生了未处理的异常。
您在“调试”->“异常”对话框中看到的选项仅允许您配置 Visual Studio 是否在所有异常(包括稍后在代码中处理的异常)上中断。这些通常被称为“第一次机会”例外。
除此之外,你永远不应该扔掉你NullReferenceException自己;这是为运行时框架保留的运行时异常。相反,您应该抛出一个ArgumentNullException.
| 归档时间: |
|
| 查看次数: |
9260 次 |
| 最近记录: |