intercept method line by line
in c#, is there any practicable way to intercept a method line after line, at run-time?
the specific application of interest would be dynamic logging:
if something within a method body threw an exception then on subsequent executions every line of that method would be logged some way or another. it is not known at compile-time which specific methods will throw an exception, so the technique should be able to interfere with most methods in the source code (which could be prepared in some generic way beforehand)
in the imaginary world, the interceptor would also expose parameters for easy identification and evaluation of the specifics of the last line of code executed.
but given this may not be possible at all, is there any rough proxy available for such a tool?
grateful as always.开发者_StackOverflow社区
I believe the only thing that comes close to what you want is ELMAH. You can modify ELMAH to do stuff -- so I guess you could use it as a starting point. However, the only way to get the line by line type functionality would be to write your own debugger -- pop in the int 13s on every line as defined in the debugging info (the pdb files you mention) -- it is a lot of work.
With ELMAH you can see a whole lot about the state of the system most importantly the stack trace.
精彩评论