You could also potentially work through the URL mechanism, as some Java
systems do. Define your own URL format and handler (let's call it the "tt"
protocol), such that YourApp.exe.config could force loading assemblies
through your URL handler (tt:file://./YourDLL.dll). Inside this, you extract
the remainder of the handler to know where to find the "real" assembly, load
it in using a PE parser (the PEAPI component from the Queensland University
folks--I can provide an URL if necessary--or the ILReader from Lutz Roeder
is what I have in mind here), extract the IL, doctor it, and re-emit the
assembly for consumption by the CLI. I'm not sure where all the drawbacks
would be--this is a totally unproven idea for the CLI. I've done it in Java,
though, if that helps. :-)
Problem: wouldn't work for the launching .exe, since that assembly (I think)
has to be made available first before the configuration stuff kicks in, so
it couldn't be loaded through the "doctoring/transforming" handler. All your
"doctored" classes would have to live in a library. John Lam's
profiler-based approach wouldn't have that limitation.
Another approach might be to do a JDO-like "enhancer" postprocessing tool.
That way you remove the hit of doing the enhancement at runtime.
Ted Neward
{ .NET && Java } Author, Instructor
http://www.javageeks.com
http://www.clrgeeks.com
----- Original Message -----
From: "Jason Whittington" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 16, 2002 1:15 PM
Subject: Re: [ADVANCED-DOTNET] Possible to change type definition when the
type is loaded?
> > Simple problem - sort of. I have a toolkit that needs to change type
> > definitions when the type is loaded.
> >
> > Is there any interface where I could "go in between" to change the
> class
> > bytecode (for certain methods) while the class is being loaded? In a
> way
> > that still goes through the verifier?
>
> I'm not aware of a way to do it at classload time but you can hook the
> IL at JIT time and doctor it up using the profiling interfaces. This is
> how Jon Lam's CLAW works.
>
> Have you thought about dynamically generating classes with
> System.Reflection.Emit or similar? This might allow you to do some of
> what you want.
>
> Jason
>
> You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.