If this were possible, it would be a tremendous boon to my team's development.

While our software is in beta, any unhandled exceptions are recorded and logged. I use the stack trace, session/form/cookie data (it's a web application) and log everything.

Could I do something like this:

1. Catch the exception.
2. Get the stack trace.
3. Get the stack frames.
4. For each frame, use Reflector to disassemble, at run time, the source code associated with the frame.
5. Use the GetFileLineNumber method of the StackFrame object to highlight the offending line of code.
6. Log the whole thing for review.

Anyone know if such a thing is possible?

Thanks,
JK
jeffkretz
0

Comments

1 comment

  • Clive Tong
    It's a good idea and I think the difficulty is in line 5. In order to map from an IL instruction to a line of code you need to have a pdb file. This pdb file is tied directly to the source code.

    If you have a pdb file that the original C# compiler generated, then when Reflector generates the source there is no guarantee that it matches the structure of the original C# - for example, there may be extra newlines etc, so the line number may well be wrong.

    Generating a pdb and source together is what the Reflector Pro engine does, but this functionality is not exported via the Reflector API.
    Clive Tong
    0

Add comment

Please sign in to leave a comment.