Re: [Ikvm-developers] Using IKVM dynamically
Brought to you by:
jfrijters
From: Michael K. <mi...@sa...> - 2011-02-08 14:17:06
|
On 08/02/2011 12:08, Jeroen Frijters wrote: > Hi Michael, > > This is fairly easy. Just create a ClassLoader subclass and you can call defineClass to load the class you generate from a byte array. There are no IKVM specific APIs required for this. Wonders will never cease - that doesn't sound easy, it sounds like zero work, since it's what we do already! > There is one gotcha: Prior to .NET 4.0 it was not possible to GC any code emitted like this so IKVM does not support unloading the classes (even when running on .NET 4.0, unless you explicitly build IKVM for .NET 4.0, in that case there is experimental support for class GC). That could be an issue for some workloads, thanks for the tip. > If you run in partial trust, .NET security could become an issue, but otherwise not. > > One other thing to keep in mind is performance, it will take more time to let IKVM convert the classes and then have .NET JIT the code than when you emit CIL directly. Also, if you emit CIL directly and can get away with using just methods (not whole types), you can use DynamicMethod, which is GC-able even on .NET 2.0. > Thanks again. Mike |