第一次机会异常 [英] A First Chance Exception
问题描述
Label1.Text = My.Computer.Clock.LocalTime.ToLongTimeString
直接窗口的输出调试是以下
类型
'System.InvalidCastException'的第一次机会异常在Microsoft.VisualBasic中发生
.dll
的第一个
机会异常
'System.InvalidCastException'在Microsoft.VisualBasic.dll中发生
在使用上下文菜单组件的以前的MSDN示例中发生相同的错误。应该我尝试... Catch ...最后
这个错误,并尝试继续前进?或者,我正在处理更严重的事情?
当您看到有关第一次机会异常的情况时,只意味着您所调用的代码中遇到了异常,但并不一定意味着代码失败。如果代码运行而不会导致程序崩溃并返回有效的值,那么没有问题。您还将在调试窗口中看到有关实现自己的try / catch块的第一次机会异常的输出。
've been running through the MSDN help documents to get a hang of Visual Basic. After trying out the example using timers --one drags a label and timer component into the designer and adds the following to the components subroutine
Label1.Text = My.Computer.Clock.LocalTime.ToLongTimeString
The output for the immediate window during debug is the following
A first chance exception of type 'System.InvalidCastException' occured in Microsoft.VisualBasic.dll
A first chance exception of type 'System.InvalidCastException' occured in Microsoft.VisualBasic.dll
The same error occurs on a previous MSDN example using a context menu component. Should I Try...Catch...Finally
this error and try to move on? Or, am I dealing with something much more serious?
When you see something about a first chance exception, it only means that an exception was caught within the code you called but does not necessarily mean that the code failed. If the code runs without causing your program to crash and returns a valid value, then do not have a problem. You will also see output in the debug window about first chance exceptions when you implement your own try/catch blocks.
这篇关于第一次机会异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!