I am writing an error log procedure (for security reasons I cannot use log4net / elmah etc), and I wanted to know if it is possible to get the line number of the line where the error occured and / or the procedure name where the error occured?
I will be creating try catch finally statement blocks, so I am hoping to get the line number of the errorhandler (or the line that caused the error) and the related procedure name.
Definition of get/have a line on US, informal. : to get or have information about (someone or something that one is trying to find) Have the police managed to get a line on any of the suspects?
to associate (with a person to whom one is romantically attached) regularly; go out (with) he is doing a line with her. See full dictionary entry for line.
Definition of 'in line/into line' If you keep someone in line or bring them into line, you make them obey you, or you make them behave in the way you want them to.
Similar words for get in line:comply (verb) obey (verb) other synonyms. fall in. obey.
Catch (Exception e)
{
string errMessage = e.Message
string errTraceDetails = e.StackTrace
}
This should give you the details you need.
If you have deployed the .pdb files as well, you should get the line number in the exception text.
I recommend against writing this yourself though. I use elmah for this type of thing everywhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With