I am trying to create some sort of error catching method that will return the error line number. We have an abort email that is sent out when a process aborts that gives us the err.number and err.description but I would like to know where is actually errors out.I know you can do the following: 1: code here2: code here3: code hereetc. And use ERL to get the number but it would be tedious to type each line out like that.Is there either a way to automatically do this or would it be easier to use Stacktrace? If Stacktrace is better could you please show me an example? Generating line numbers in exception stack traces is a built-in feature for the CLR. You do however have to provide the information it needs to map a code address to a line number.
Switch to the Release configuration of your project. Project + Properties, Compile tab, Advanced Compile Options. Change the 'Generate debug info' setting from pdb-only to Full. Deploy the.pdb files along with your program.Beware that the line number you get is always an estimate so do not blindly trust what you see. The mapping is imperfect due to the jitter optimizer inlining methods and otherwise moving code around to make the program run faster. TryDim x As Integerx = ' 'Catch ex As ExceptionDim trace = New Diagnostics.StackTrace(ex, True)Dim line As String = Strings.Right(trace.ToString, 5)Dim nombreMetodo As String = 'Dim Xcont As Integer = 0For Each sf As StackFrame In trace.GetFramesXcont = Xcont + 1nombreMetodo = nombreMetodo & Xcont & '- ' & sf.GetMethod.ReflectedType.ToString & ' ' & sf.GetMethod.Name & vbCrLfNextMessageBox.Show('Error en Linea number: ' & line & ex.Message & vbCrLf & 'Metodos: ' & vbCrLf & nombreMetodo)End Try.
![Code Code](https://i.ytimg.com/vi/LO13vUx-nBA/maxresdefault.jpg)
Feb 15, 2017 ADO Run-Time Errors.; 3 minutes to read; Contributors. In this article. ADO errors are reported to your program as run-time errors. You can use the error-trapping mechanism of your programming language to trap and handle them. No disagreement here in regards to last resort. We use it mainly for catching a) wrong version of IBM Client Access installed b) permission issues for databases. 99.99% of the time this will happen once per user and is rare, like once or twice in a 12 month time period.