How to: Merge several assemblies in one assembly



By ganton ~ August 5th, 2008. Filed under: .Net.

Today, a colleague of mine Zlatko run into a problem of how to combine several assemblies into one assembly. He started a discussion with me and we decided that I’ll make a research of the problem. After a short research I found several links with applications which allows to merge assemblies. First of all and most important link is ILMerge application.

ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly. It is freely available for use from the Tools & Utilities page at the Microsoft .NET Framework Developer Center.

You can download it from here and use it. It is a console utility and thanks to the smart people there is a GUI wrapper for it. Actually, there are several GUI wrappers but I decided to use NuGenUnify for my tests. It is downloadable in a zip file and after unzipping it you can use it. But before to use it you should download and install ILMerge. That is why because after installing NuGenUnify needs a link to ILMerge in order to use work.

The use of NuGenUnify is quite simple. I use for my tests the MDI application for my other post that consists of two Dlls and one executable. I merged both Dlls to the executable and all works fine. Below is the sample of how I used NuGenUnify.

The Primary Assembly is mine executable and other assemblies are mine data access and business logic assemblies. The output is a new assembly which includes all name-spaces with their classes and its references are corrected. Below you can see how result assembly looks like in Reflector.

Thanks to Zlatko for sharing with me this problem because I learned something really useful in some situations and new for me.

Leave a Reply