Is it possible to remove unused code/assemblies in .NET?

血红的双手。 提交于 2019-12-05 19:42:11

My boss worked with an obfuscation product that did this, by bringing the code that was used into a combined assembly. Can't remember what it was called though, might have been DotNet Reactor (we used a few different products before settling on one).

There's a product called SmartAssembly that does this. It's a bit pricey, at least for me.

Just as a caveat, make sure what you are doing is permissible according to the EULA of the vendor company which made library.

2Mb is not large.

If you feel it's too much, and since it's your code, you should consider refactoring it into separate assemblies, still using the same namespaces. That way, your code could reference only the assemblies it needs.

If it's open source you can take a look at the code and selectively take out what you want and build a separate assembly.

If it's not open source you can use Reflector on the assembly and wring out the code you want to keep (and all its dependencies) and then rebuild it in your own assembly. I'm not sure how legal that is. It probably depends on the license of your library.

You can do that, but needs some programming. take a look at mono cecil project, you can open the assembly, remove the unwanted types and save it. the programming is involved with determining what types are not used (type A is using type B, so if YOU use type A, you should keep type B)...

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