Disable Visual Basic Err object while debugging

拜拜、爱过 提交于 2019-12-25 03:01:12

问题


I have a windows service written in VB.NET and for error logging at runtime it uses the Err object of Visual Basic. When I am debugging the service it is not giving me any error but at the same time it is setting the Err object with number 13 which means I have a type mismatch somewhere (According to Error List) Any idea how I can forcefully throw the runtime exception while debugging? I have tried commenting the below code but no luck:-

On Error Resume Next

回答1:


You can use Err.Raise() method or Throw Err.GetException() method if Err has any error.

If Err.Number <> 0 Then
    Throw Err.GetException()
End If

OR

If Err.Number <> 0 Then
    Err.Raise(Number:=Err.Number, Source:=Err.Source, Description:=Err.Description, HelpFile:=Err.HelpFile, HelpContext:=Err.HelpContext)
End If


来源:https://stackoverflow.com/questions/32800427/disable-visual-basic-err-object-while-debugging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!