Articles → .NET → ILMerge utility

ILMerge utility






What is ILMerge utility?





Download




Picture showing the web page to download the ILMerge utility

Click to Enlarge



Picture showing the ILMerge folder once the ILMerge utility is installed

Click to Enlarge


Example












namespace ILMergeLib {
	public class MyClass {
		public string SayHello(string name) {
			return string.Format("Hello {0}", name);
		}
	}
}








Picture showing adding the reference of ILMergeLib.dll in the project

Click to Enlarge



using System;
using ILMergeLib;

namespace ILMergeDemo {
	class Program {
		static void Main(string[] args) {
			MyClass obj = new MyClass();
			Console.WriteLine(obj.SayHello("gyan"));
			Console.ReadLine();
		}
	}
}





Running the executable file






Picture showing the error message when executable file is run

Click to Enlarge




Merging executable and DLL files








Picture showing the context menu when right-click on the project file in solution explorer

Click to Enlarge





"$(ProjectDir)ilmerge.exe" /target:exe /out:"$(TargetDir)ILMergeDemo_final.exe" "$(TargetDir)ILMergeDemo.exe" "$(TargetDir)ILMergeLib.dll" /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"



















Output




Picture showing the output of using the ILMerge utility

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, August 3, 2017

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250