Search code examples
.netmono.cecil

Mono.Cecil Instantiate dynamically created type


How do I create an instance of a type I've just created with AssemblyDefinition/TypeDefinition (I mean in runtime)? Currently, I save the created assembly as a file, read it with System.Reflection.Assembly.Load, find the type, find its constructor, and finally call the constructor.

Is there a way to do that entirely in memory without the temporary file?


Solution

  • You could save to memory stream, then load the assembly from the bytes.