将DynamicMethod保存到磁盘 [英] Saving a DynamicMethod to disk

查看:69
本文介绍了将DynamicMethod保存到磁盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了使用DynamicMethod在运行时生成方法的代码。我还需要修改一些正在生成的代码。

I have inherited code that uses DynamicMethod to generate methods at runtime. I also need to modify some of the code that is being generated.

由于我是MSIL的n00b会员,所以我希望能够将生成的代码加载到Reflector并确保代码能够完成我所希望的;)

Since I am a n00b at MSIL, I would love to be able to load the generated code up in Reflector and ensure that the code does what I pray that it does ;)

我只能弄清楚如何将匿名托管的DynamicMethods程序集序列化到磁盘上。这可能吗?如果可以,怎么办?

Only, I can't figure out how to serialize the "Anonymously Hosted DynamicMethods Assembly" to disk. Is this possible? If so, how?

推荐答案

我认为,如果您想在Reflector或dotPeek中加载该方法,则需要创建一个实际组装。为此,使用 MethodBuilder 而不是 DynamicMethod 。它们的大多数用法应相同。

I think that if you want to load the method in Reflector or dotPeek, you need to create an actual assembly. To do this, use MethodBuilder instead of DynamicMethod. Most of the usage of them should be the same.

这篇关于将DynamicMethod保存到磁盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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