I have a .NET assembly which has defined a type T at compile time, and I have instantiated an object my_t as an instance of this type.
I am wondering if it is possible in .NET to use the runtime compiler services to re-compile this class, then load the new class definition into the currently executing assembly, so when I call methods off of my_t, they will use the new code.
I am not changing the signatures of any of the methods, just the method bodies.
Any .NET gurus out there know if this is possible? Thanks in advance for any help!
A .NET object can’t change type at runtime; it’s a fundamental assumption in the CLR.
A few suggestions:
Tto forward calls to the right type as appropriate. It can forward to a type that gets compiled at runtime if you want to.