Executing MSIL dynamically

  • Thread starter Thread starter Roy V
  • Start date Start date
R

Roy V

I have succesfully been able to use ILDASM.exe to disassemble a dll
into MSIL instructions. I would like to store this MSIL in a text
field in SQL Server and then call it up in a .NET application for
execution. How is this done? I have looked at Reflection.Emit, but
it seems that you have to generate IL code and then run it, I already
have the MSIL code, I just want to run it.

Thanks for any help,

Roy
 
Haven't tried this myself (yet), but have a look at the Assembly class.
It has Load method that expects a byte[]. You can pass in your
IL in there and see if that does the job.

Of course, that only loads the IL/assembly. You then use reflection
to call on the assembly's entrypoint.

Cheers!
 
You could launch ILASM using Process.Start, and then load the compiled
Assembly via Reflection. Ok?

GP
 
Thanks for all the help. Calling ILASM.exe should do the trick,
hopefully my boss will like it. Thanks again.

Roy
 
Back
Top