Is it possible to create a class during run-time and use it?
I am NOT referring to compiling code at run-time, generating a new assembly, loading it, executing it, etc. Reflection is a one-way street in that it can give you run-time info about your currently loaded assembly or one that you load from file or memory.
My question is more about injection I guess. Can you create a class at run-time within your own app domain and make it do anything useful?
Is it possible to create a class during run-time and use it?
Yes, you could use Reflection.Emit. You may also checkout Castle.DynamicProxy which simplifies the process of manually generating the IL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With