不抛出类中的VB.NET错误

时间:2014-03-16 12:29:36

标签: vb.net exception exception-handling

我在类中有以下代码:

Private WithEvents AH As ActiveHomeScriptLib.ActiveHome

Public Sub New()

    Try
        AH = New ActiveHomeScriptLib.ActiveHome
    Catch ex As Exception
        WriteLog("#clsCM15Pro_Class_Initialize: " & Information.Err().Description & ", err.number: " & CStr(Information.Err().Number) & ", Params: '" & "" & "'")
    Finally

    End Try

End Sub

未到达“WriteLog”行。 我在“End Sub”设置了一个断点,但它永远不会到达。

我激活了以下异常: enter image description here

有没有人看到我在这里可能犯的任何错误会导致我遇到的行为?

编辑:我现在已经创建了一个新项目。 只有一个表格,上面有一个按钮。

单击该按钮可执行以下操作:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Dim c As clsCM15Pro
    c = New clsCM15Pro

    MsgBox("Blah!")

End Sub

但是没有显示消息框。相反,我的应用程序只需在单击按钮后退出IDE。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

AH内部引用了丢失的DLL。当它没有找到这个DLL时,这会导致意外的行为:VB.NET中没有抛出任何错误。 解决这个问题的唯一方法是(没有AH代码......它是第三方DLL),首先要检查所讨论的DLL是否存在,并且只有当它存在时,才继续。否则,请跳过这种奇怪的行为。