modify the assembly on runtime?

删除回忆录丶 提交于 2019-12-01 22:14:40

You can use Mono Cecil to modify the assembly before you load it.

You can save the modified assembly to a byte array, then call Assembly.Load to load the byte array.

I don't think you can do that. But you can generate new classes in a new, in-memory assembly using Reflection.Emit.

That is a lot of work though. You can get help from a framework such as Castle DynamicProxy, which allows you to generate proxies for your classes at runtime. This way you can run any code before or after the original methods run, or change the methods totally by not calling into the original method.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!