Modifying Existing .NET Assemblies

若如初见. 提交于 2019-11-28 05:30:35

You can use MethodInfo.GetMethodBody().GetILAsByteArray(), modify that, and then plug it back into MethodBuilder.CreateMethodBody().

Mono.Cecil also allows you to remove the strong name from a given assembly and save it back as an unsigned assembly. Once you remove the strong name from the assembly, you can just modify the IL of your target method and use the assembly as you would any other assembly. Here's the link for removing the strong name with Cecil:

http://groups.google.com/group/mono-cecil/browse_thread/thread/3cc4ac0038c99380/b8ee62b03b56715d?lnk=gst&q=strong+named#b8ee62b03b56715d

Once you've removed the strong name, you can pretty much do whatever you want with the assembly. Enjoy!

It would help if you could provide a more specific use case, there are probably better ways to fix your problem than this.

In .NET 3.5 it's possible to add extension methods to existing framework classes, perhaps that is enough?

One important point: if the assembly is signed, any changes will fail and you'll end up with a dud.

.NET Framework assemblies are signed and just as Joel Coehoorn said you'll get a dud.

You could load the assembly using IronRuby, and mixin all the functionality you can dream of

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