This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.


Creating Signed Assemblies Using ILMerge

ILMerge allows multiple assemblies to be combined into a single executable or dynamic linked library (DLL), simplifying their use and minimising the number of files in an installation. ILMerge can also be used to sign those merged assemblies.

Signing Merged Assemblies

ILMerge is a utility that can be downloaded from the Microsoft web site. It allows a group of assemblies to be combined into a single executable or DLL. During this process, a new assembly is created and contains the contents of a primary assembly and a number of secondary assemblies.

Under the default settings, the merged assembly is not signed. This can be a problem if the software that uses it requires an assembly with a strong name. Luckily, ILMerge includes an option that permits the merged assembly to be signed using a key file, which will usually have an extension of SNK. Key files can be generated by Visual Studio or the strong name tool (sn.exe) that ships with the .NET Framework.

To merge assemblies and sign the result, you should use the /keyfile switch. The switch is followed by a colon (:) and the name of the key file. The sample below shows the correct use of the switch. For simplicity, I have omitted the paths to ILMerge, the key file and the assemblies being merged.

ilmerge /out:Merged.dll /keyfile:key.snk Primary.dll Secondary.dll

Signing Without Merging

ILMerge can also be used to sign a single .NET assembly, even when the source code is unavailable. To achieve this, the /keyfile switch is used but no secondary assemblies are specified.

ilmerge /out:Merged.dll /keyfile:key.snk Primary.dll
4 August 2010