Calling private constructors with Reflection.Emit?
- by Jakob Botsch Nielsen
I'm trying to emit the following IL:
LocalBuilder pointer = il.DeclareLocal(typeof(IntPtr));
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Stloc, pointer);
il.Emit(OpCodes.Ldloca, pointer);
il.Emit(OpCodes.Call, typeof(IntPtr).GetMethod("ToPointer"));
il.Emit(OpCodes.Ret);
The delegate I bind with has the signature
void* TestDelegate(IntPtr ptr)
…