This question is a follow up on Unhandled exception: System.IO.FileNotFoundException: The file or assembly “System.Private.CoreLib” could not be found in custom generated assmbly.
I basically want to transform a Func at runtime to IL code, that will then be executed in the generated assembly.
For this I created a function with the following signature:
public void AddExecutingFunctionToIL(ILGenerator parentIlGenerator, TypeBuilder typeBuilder, Func<object[], object> function)
I can’t figure out how I can achive this, as referencing function
after generating the assembly is not possible (so just calling parentilGenerator.Emit(OpCodes.Call,function.Method);
won’t do the trick. I also tried using the Mono.Reflection package to transform the function delegate to IL code, sadly I couldn’t quite figure out how to do this properly.
Help would be gladly appreciated.