问题
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