IL 发出 - 存储然后加载时操作可能会破坏运行时的稳定性
嘿,所以我有以下 IL:
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ret);
效果很好。它基本上返回给定的参数。 然而,这
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Stloc_0);
il.Emit(OpCodes.Ldloc_0);
il.Emit(OpCodes.Ret);
不起作用。它崩溃并出现异常“操作可能会破坏运行时的稳定性。”。 现在,我知道这样做的目的是没有用的,但我正在努力一步一步地实现我的目标。 为什么那不起作用?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你申报本地了吗? arg0 和 loc0 的类型是否匹配?您还知道实例方法中的 arg0 是 this 引用,对吧?
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?