protected void EmitLoadTargetObject(Type expectedType) { _il.Emit(OpCodes.Ldarg_0); // target object is the first argument if (expectedType.IsValueType) { _il.Emit(OpCodes.Unbox, expectedType); } else { _il.Emit(OpCodes.Castclass, expectedType); } }