IL发射-在存储然后加载时,操作可能会破坏运行时的稳定性 [英] IL emit - operation could destabilize runtime when storing then loading

查看:80
本文介绍了IL发射-在存储然后加载时,操作可能会破坏运行时的稳定性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,所以我有以下IL:

Hey, so I have the following IL:

il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ret);

哪个工作正常。它基本上返回给定的参数。
这是

Which works fine. It basically returns the argument given. This, however:

il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Stloc_0);
il.Emit(OpCodes.Ldloc_0);
il.Emit(OpCodes.Ret);

不起作用。它崩溃,并带有操作可能破坏运行时的稳定性的异常。
现在,我知道这样做的目的是没有用的,但我正在努力一步步实现自己的目标。
为什么不起作用?

Does not work. It crashes with the exception "Operation could destabilize the runtime.". Now, I know that the purpose of that is useless but I'm trying to reach my goal by small steps. Why does that not work?

推荐答案

您是否声明了本地名称? arg0和loc0的类型是否匹配?您还知道实例方法中的arg0是此引用,对吧?

Have you declared the local? Does the type of arg0 and loc0 match? Also you know that arg0 in an instance method is the this reference, right?

这篇关于IL发射-在存储然后加载时,操作可能会破坏运行时的稳定性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆