| Author |
Message |
jeffkretz
Joined: 02 Apr 2009 Posts: 5
|
Posted: Fri Mar 18, 2011 2:08 am Post subject: Possible to use Reflector at run time? |
|
|
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 |
|
| Back to top |
|
 |
Clive Tong
Joined: 04 Dec 2008 Posts: 281
|
Posted: Tue Mar 22, 2011 10:22 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|
|
All times are GMT + 1 Hour
|
| Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group