Functions:
Code:
    Public Function GetExceptionText(ByVal Ex As Exception) As String
        Dim trace As StackTrace = New StackTrace(Ex, True)
        Dim msg As String = Ex.Message & vbCrLf
        Try
            For Each frame As StackFrame In trace.GetFrames
                msg &= vbCrLf & "At " & frame.GetMethod.Name & " (" & frame.GetFileLineNumber & ")"
                Dim name As String = System.IO.Path.GetFileName(frame.GetFileName)
                If name <> "" Then msg &= " in " & name
            Next
        Catch
        End Try
        Return msg
    End Function
    Public Sub ShowExceptionDialog(ByVal Ex As Exception)
        MessageBox.Show(GetExceptionText(Ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Sub
In the catch handler, simply add this:
Code:
ShowExceptionDialog(Ex)
It will show the entire stack trace, allowing you to see exactly at which line the error occurred.