我在一些偶尔会抛出预期异常的代码周围放置了一个 try/catch 块,但不是捕获它并显示消息框,而是停止调试器并提醒我该异常未处理。
如何处理此异常,以便我的代码在异常发生时不会停止?
Friend myDevInfo As New devInfo
''' <summary>
''' Closes the device handle obtained with CreateFile and frees resources.
''' </summary>
'''
Friend Sub CloseDeviceHandle()
Try
WinUsb_Free(myDevInfo.winUsbHandle)
If Not (myDevInfo.deviceHandle Is Nothing) Then
If Not (myDevInfo.deviceHandle.IsInvalid) Then
myDevInfo.deviceHandle.Close()
End If
End If
Catch ex As System.AccessViolationException
MsgBox("System.AccessViolationException")
Catch ex As Exception
Throw
End Try
End Sub