ILMerge to the rescue

Is your solution plagued by a large number of assemblies that need to be loaded? Well ILMerge will merge them together into one single assembly. A single assembly is so much easier to distribute after all [:)]
Download it here. Or read more about it over here.
One interesting thing is that the readme says “It does not yet support Rotor or Mono“. Now how often does Microsoft use the not yet in combination with Mono? Interesting thought!

5 thoughts on “ILMerge to the rescue

  1. Hi I am using VS2005 and in the postbuiltevent of the project i use the following command :

    ILMerge.exe /wildcards /log:ILMerge.log /out:$(TargetDir)Merged_Tool.exe $(TargetPath) $(TargetDir)Interop.*.dll

    What I wanted to do is merge the program generated .exe and all the Interop*.dll into the executable directory into the Merged_Tool.exe and Copy this Merged_Tool.exe into some separtae directory (without copying the Interop*.dlls into that directory) and wants to successfully run it. When I run the application it gives “FileNotFoundException” because all the Interop dll’s are not there in this “Merged” executable directory, when I copy all thse files over there it works fine.

    Can any one solve my problem as I dont want to distribute these Interop dlls to the user.

    I have seen the log and the log simply says that all the assemblies are merged successfully

  2. Hi Hem,

    When I tried your PostBuildEvent it failed because it was unable to find the assemblies. In my case that was because of spaces in directory names. Not sure if you issue is the same but changing the command to:
    “c:\Program Files\Microsoft\ILMerge\ILMerge.exe” /wildcards /log:ILMerge.log /out:”$(TargetDir)Merged_Tool.exe” “$(TargetPath)” “$(TargetDir)Interop.*.dll”

    fixed the problem for me. Copying just the Merge_Tool.exe to another directory was all that was needed to run the app.

    Another possible reason could be the COM server you are using. As you didn’t specify it I just used Visual FoxPro which has a pretty standard typelib.

  3. ILMerge is helpfull in some scenarios, but with others it can be dangerous.

    For example – if you merge 2 assemblies with the same non public type on both – it will work but will change the name of the type.

    is it a problem? yes if you use reflection…
    and you can end up with multiple instance of a singleton too.

    don’t forget the memory footprint of the merged assembly.

    so do use this tool, but only after you understand the implications.


  4. I try to run NuGenUnify which use ILMerge but it keep give me this error result :

    Trying to read assembly from the file ‘D:\workspace\tes ilmerge\tesdll.dll’.
    Could not load assembly from the location ‘D:\workspace\tes ilmerge\tesdll.dll’. Skipping and processing rest of arguments.

    how to fix it?

Leave a Reply

Your email address will not be published. Required fields are marked *