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

Closed

Eliminate MethodAccessException for classes derived from generics

description

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);
        }
        else
        {
            _ilGen.Emit(OpCodes.Callvirt, method);
        }
    }
Now everything works fine.

According to this http://blogs.msdn.com/haibo_luo/archive/2006/08/13/698719.aspx
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.

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

comments