-
-
Notifications
You must be signed in to change notification settings - Fork 91
Description
Using Expression.Call with an instance can generate this error when CreateType is called.
A similar issue was created: #300
I'm using Lokad.ILPack to save generated compilations to dll by using CompileFastToIL into an ILGenerator and then creating the type. For much of my code generation, this works fine. Some routines create a static method call without an instance parameter to Call, but the ones that do pass an instance parameter to call will fail.
A call made through:
var callmethod = Expression.Call(
Expression.Constant(instance), typeof(ExpressionMethods).GetMethod("EmptyInstanceMethod")!);
it will always generate this error message. A call without that instance constant will work just fine.
Note: the resulting compiled delegate does work correctly. I am just unable to save the resulting code or generate it manually through CompileFastToIL using my own DynamicAssembly/Module.
I've tried using the current nuget version as well as the latest main branch on github.