在Visual Studio中捕获JIT错误



我试图将用户在vb.net应用程序中收到的任何错误写入日志文件,我想知道是否有任何方法可以捕获JIT错误,如果这是什么执行此操作的代码?

谢谢

基于NBK的说法,您可以做类似的事情

Private Sub LogEx()
    Try
        'Some stuff that will fail
    Catch ex As Exception
        LogException(Environment.UserName, ex.ToString)
    End Try
End Sub
Private Sub LogException(ByVal Username As String, Ex As String)
    Dim LogFilePath As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "MyLog.txt"
    Dim MyLogFile As IO.StreamWriter =
        My.Computer.FileSystem.OpenTextFileWriter(LogFilePath , True)
    MyLogFile.WriteLine(Username & "---" & Ex)
    MyLogFile.Close()
End Sub

最新更新