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

Get line number from exception stack trace

P: n/a
Hi there,

The .pdb files are generally not installed in a production environment.
As a result, when an exception occurs, the runtime can't resolve the
lines of the code where the problem happened. Instead, one gets the
offsets, e.g.:

[NullReferenceException: Object reference not set to an instance of an
object.]
MyClass.DoSomething(String s) +554

If I haven't changed the source code on my development machine, is
there any way to translate the offset (+554) into the line number?

I tried using ILDASM and looking at the IL but couldn't find anything
that would correspond to offset +554. ILDASM showed the method has
offsets from IL_0000 to IL_00bc

Thanks,

-Oleg.

May 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ol*********@gmail.com wrote:
The .pdb files are generally not installed in a production environment.
This is safe to do, by the way. You can build PDBs for your release
build, and you'll get line number information. Mind that generating the
string which includes the stack trace will be more expensive, though,
because the pdb will be opened up and searched.
I tried using ILDASM and looking at the IL but couldn't find anything
that would correspond to offset +554. ILDASM showed the method has
offsets from IL_0000 to IL_00bc


The offset will probably be in the machine code generated from the MSIL.
You could try debugging the release build in Mixed mode (with "Unmanaged
debugging" turned on) and putting a breakpoint inside the method. By
switching to the CPU view you'll be able to see what happened at that
offset, after you convert it to hex.

-- Barry

--
http://barrkel.blogspot.com/
May 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.