Hi!
Does anyone know if it's possible to modify a method at runtime?
I've searched around and all that I find is the possibility to
extend classes at runtime, adding properties, methods etc.
(TypeBuilder, MethodBuilder, reflection etc)
What I actually want to do is to inject debug support dynamically,
starting with enter/leave tracing..
All tips appreciated
Stefan
Ben Blair - 16 Sep 2003 00:14 GMT
Stefan,
Take a look at Aleksandr Mikunov's excellent article on
using the Profiling API to re-write msi on the fly (right
before it goes to the JIT).
http://msdn.microsoft.com/msdnmag/issues/03/09/NETProfiling
API/default.aspx
- Ben Blair
- benblair@Association of Computing Machinery dot org
>-----Original Message-----
>Hi!
[quoted text clipped - 10 lines]
> Stefan
>.
Thomas Tomicek [MVP] - 16 Sep 2003 05:45 GMT
And then stay away from it for the reasons documented in the documentation.

Signature
Regards
Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
> Stefan,
>
[quoted text clipped - 25 lines]
> > Stefan
> >.
Thomas Tomicek [MVP] - 16 Sep 2003 05:45 GMT
> Hi!
>
> Does anyone know if it's possible to modify a method at runtime?
No, not unless you go for the profiler API which is a TERRIBLE bad idea to
do for a number of reasons, one being that it is a develloper API which your
user may not have access to.
I actually stay away from thei API aolso for another reason: I like to
profile my programs, and there can only ever be ONE user of this API.

Signature
Regards
Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
Ice - 19 Sep 2003 14:20 GMT
You have to implement some form of interception (at a performance risk).
What I have seen done (and implemented) is creating a proxy for all objects
and then having the proxy write trace info before and after calling the
"real" object to execute the method.
can be 5 - 200 times slower.
ice
> Hi!
>
[quoted text clipped - 8 lines]
> All tips appreciated
> Stefan