VB.NET - How to get only the error line number ( VB Net)

Asked By Dilip Kovoor on 13-Apr-05 08:43 AM
Hi all, 
   I wanted to get just the line number where the error had happend. Now when I used Catch ex as Exception and when i try to use ex.message, or stack trace I get the error message and line number merged together. Is there a way I can get just the error line number alone which can be used in the release mode. 
Also anybody who nows tools which will support inserting line numbers to the application in vb.net?
with regards & thanks
Dilip
Glenn replied to Dilip Kovoor on 19-Oct-10 03:18 PM
You can get the Error line and column using system.diagnostics lik this

      Dim shortstr As String = "1234"
      Try
          Dim ErrorPopper As String = shortstr.Substring(5)
      Catch ex As Exception
          Dim errormess As New StringBuilder(Me.ToString + " Error details")
          Dim trace = New System.Diagnostics.StackTrace(ex, True)
          errormess.AppendLine(ex.Message)
          errormess.AppendLine(trace.GetFrame(0).ToString)
          errormess.AppendLine(Me.ToString)
          errormess.AppendLine("LIne number:" & trace.GetFrame(0).GetFileLineNumber().ToString)
            errormess.AppendLine("Column:" & trace.GetFrame(0).GetFileColumnNumber())
      End Try