Best practices for merging assemblies?

血红的双手。 提交于 2019-12-04 02:55:36
David Schmitt

The short, easy version:

Every reference within one process to a given Assembly should reference the same version.

If you don't, you might get into deep troubles because one part of the app cannot talk to another due to version mismatch.

Even with "really private" stuff like log4net you might miss out on possibilities for shared configuration space, like using a common root logger for all parts of the app. Of course, the final call in this case is -- as always -- with the responsible developer.

See also this other question about ILMerge and 3rd party assemblies.

The biggest reason we use ILMerge is to make our obfuscation step that much more difficult to reverse. By merging them together using the /internalize flag the obfuscator can then rename the public classes and methods that we merged into the parent assembly.

From IL merge Documentation: "[Internalize] controls whether types in assemblies other than the primary assembly have their visibility modified. When it is true, then all non-exempt types that are visible outside of their assembly have their visibility modified so that they are not visible from outside of the merged assembly"

If the assemblies are kept separate then the obfuscator won't rename them.

BTW Eazfuscator is awesome, and free: http://www.foss.kharkov.ua/g1/projects/eazfuscator/dotnet/Default.aspx

We don't merge libraries at all. I can't see much advantage in merging libraries together that you can't get but just building them in one assembly in the first place.

I can see the benefits in merging libraries with an EXE. That could be real handy. The problem with merging libraries together is that they may have different versions of a dependancy in your EXE and that can make for uncomfortable bedfellows.

I don't think merging dlls together could be considered best practice except when you are merging them into an EXE to present a single file instead of multiple files.

I suppose there might be some advantage with regards to keeping a bunch of localized assemblies in one (which, I am not even sure you can do)

I would not merge libraries from other vendors - because they often have their own licensing, and updating them would require you to redistribute a new version of your code.

Merging your own libraries may be advantageous if you have many libraries to keep the directory neat, or make sure that some code will ALWAYS be with the main executing assembly.

I think ILMerge does better with libraries being merged into an EXE, so that you have one file instead of many.

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