Catch JIT Errors in Visual Studio

Asked by At

I am trying to write any errors out our users receive in a vb.net application to a log file and I was wondering if there is any way to catch JIT errors and if so what is the code to do this?

Thanks

1 Answers

0
user238615 On

Based on what nbk is saying, you could do something like this

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