Geting Source Code from Exception.

  • Thread starter Thread starter Gary van der Merwe
  • Start date Start date
G

Gary van der Merwe

I have a web application which has a custom error handler
which displays frendly message to user and emails me the
details.

The standard Asp.NET error handler page will, if the
project is in debug mode, display the line of code that
the error occoured on, as well as the previous and next 3
lines.

I would realy like to put this info in to the email that I
send to myself.

I think it might start with Excepition.TargetSite.
..
 
Gary,

I think that what you want to do is use the StackTrace instance which is
exposed by the exception thrown. You can then call ToString to get the code
that caused the error, I believe.

Hope this helps.
 
Ha I figered out how they (std ASP.Net Error Page) do it -
not what I was hopeing though.

They read the code from the file. They get the file name
and line number from the stack trace. If file name of the
first Stack Frame is not availible, it looks for the
second, ect..

I concluded this by renaming the file that the exception
was been thrown in. It then showed the code for the class
that the method was called by.

I was realy hoping that the code was stored in the PDB
file, and that I could access it somehow.

Gary.
 
Back
Top