Red Gate forums :: View topic - Possible to use Reflector at run time?
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
.Net Reflector 6.x and .NET Reflector 6.x Pro
.Net Reflector 6.x and .NET Reflector 6.x Pro forum

Possible to use Reflector at run time?

Search in .Net Reflector 6.x and .NET Reflector 6.x Pro forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
jeffkretz



Joined: 02 Apr 2009
Posts: 5

PostPosted: Fri Mar 18, 2011 2:08 am    Post subject: Possible to use Reflector at run time? Reply with quote

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
View user's profile Send private message
Clive Tong



Joined: 04 Dec 2008
Posts: 283

PostPosted: Tue Mar 22, 2011 10:22 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. 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