Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a line # and proc name in asp.net

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.

like image 806
user279521 Avatar asked Jul 28 '10 18:07

user279521


People also ask

What does it mean to get a line?

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?

What does a line mean in slang?

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.

What does it mean to get someone in 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.

What is the word for getting in line?

Similar words for get in line:comply (verb) obey (verb) other synonyms. fall in. obey.


2 Answers

Catch (Exception e)
{
string errMessage = e.Message
string errTraceDetails = e.StackTrace
}

This should give you the details you need.

like image 94
LearningCSharp Avatar answered Sep 30 '22 00:09

LearningCSharp


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.

like image 22
ConsultUtah Avatar answered Sep 30 '22 00:09

ConsultUtah