By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,896 Members | 2,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,896 IT Pros & Developers. It's quick & easy.

How to get source code during exception?

P: n/a
During my code's processing of an exception, I would like to format the
exception myself.

I can get almost everything (I can get exception itself, stack trace,
file name, line number, method, parameters) but cannot seem to get the
source code where the exception occurred.

The ASP.NET exception handler does display the source code, but I
cannot seem to get it myself and, hence, display it myself.

Through what objects (e.g., System.Diagnostics, System.Reflection,
etc.) do I need to go through in order to get the source code?

P.S. Yes, I compile in Debug mode and, yes, there a .pdb file
available, if that helps.

Thank you.

Oct 2 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Use System.Diagnostics.StackTrace.

<sa*******@gmail.comha scritto nel messaggio
news:11********************@i42g2000cwa.googlegrou ps.com...
During my code's processing of an exception, I would like to format the
exception myself.

I can get almost everything (I can get exception itself, stack trace,
file name, line number, method, parameters) but cannot seem to get the
source code where the exception occurred.

The ASP.NET exception handler does display the source code, but I
cannot seem to get it myself and, hence, display it myself.

Through what objects (e.g., System.Diagnostics, System.Reflection,
etc.) do I need to go through in order to get the source code?

P.S. Yes, I compile in Debug mode and, yes, there a .pdb file
available, if that helps.

Thank you.

Oct 3 '06 #2

P: n/a

sa*******@gmail.com wrote:
During my code's processing of an exception, I would like to format the
exception myself.

I can get almost everything (I can get exception itself, stack trace,
file name, line number, method, parameters) but cannot seem to get the
source code where the exception occurred.

The ASP.NET exception handler does display the source code, but I
cannot seem to get it myself and, hence, display it myself.

Through what objects (e.g., System.Diagnostics, System.Reflection,
etc.) do I need to go through in order to get the source code?

P.S. Yes, I compile in Debug mode and, yes, there a .pdb file
available, if that helps.

Thank you.
I believe that the information displayed in the stack trace (function
names, argument lists) is formatted from Reflection data. The only
exception would be the line numbers, which are probably discovered by
ferreting around in the .pdb file.

Oct 3 '06 #3

P: n/a
<sa*******@gmail.comwrote in message
news:11********************@i42g2000cwa.googlegrou ps.com...
During my code's processing of an exception, I would like to format the
exception myself.

I can get almost everything (I can get exception itself, stack trace,
file name, line number, method, parameters) but cannot seem to get the
source code where the exception occurred.
You have the filename and line number, open that file and read to that line.

Oct 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.