This project has moved. For the latest updates, please go here.


Eliminate MethodAccessException for classes derived from generics


EmitCall doesn't always generate legitimate methods if the method is implemented on a base class that is generic. Change the DynamicEmit helper class to only use EmitCall for VarArgs methods and use general Emit for all others.
Per this:
Hi. I found the solution. I changed Call method in DynamicEmit class to this:

public void Call(MethodInfo method)
        if (method.IsFinal || !method.IsVirtual)
            _ilGen.Emit(OpCodes.Call, method);
            _ilGen.Emit(OpCodes.Callvirt, method);
Now everything works fine.

According to this
EmitCall is mainly for varargs methods and you can (should) use Emit when you do not use varargs.
I do not understand MSIL but I might be a bug in EmitCall or I don't know.

Have a nice day.

Closed May 25, 2007 at 9:08 PM by IDisposable
Added check for varargs methods and use the old EmitCall method, otherwise use simple Emit call.