hi
how i can use ILMerge for making my c# program portable?
you can see it's web site here and download it
thanks

Dani AI

Generated

Short answer: ILMerge alone will not make your program run on a machine without .NET installed. ILMerge (and ILRepack-style tools) only combine managed assemblies into a single assembly — they do not bundle the CLR itself — so the target system still needs the appropriate .NET runtime. This is the distinction was trying to point out. (ILMerge repo, single-file/self-contained concept).

Practical options depending on your constraints:

  • Move to modern .NET (net6+/net7+/net8+) and publish a self-contained single-file executable that includes the runtime (platform/arch specific). Example CLI publish (Windows x64):

    dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:SelfContained=true -p:PublishTrimmed=true

    You must publish per runtime identifier (RID) and test trimming because reflection/dynamic code can break. (single-file docs, dotnet publish).

If you must stay on .NET Framework: ILMerge/ILRepack can reduce the DLL count; Costura.Fody can embed DLLs as resources and load them at runtime — both make distribution simpler but do not remove the framework requirement. For cross-platform native bundling you can use Mono's mkbundle to include the Mono runtime. (ILRepack, Costura, mkbundle).

For a true native binary with no runtime dependency consider Native AOT (or rewriting to native C/C++ as suggested). Native AOT produces self-contained native executables but imposes limits (no runtime codegen, reflection caveats) and remains RID-specific — test thoroughly before shipping. (Native AOT overview).

Bottom line: ILMerge helps reduce file count, but to run without installing .NET you need to bundle or AOT-compile the runtime — choose self-contained publish, mkbundle, or Native AOT depending on target platforms and runtime features used.

Recommended Answers

All 4 Replies

Not sure what you are asking here. ILMerge lets you package all your assemblies into one assembly. Did you mean you want to package the .NET assemblies too so that the end user doesn't need .NET installed? It would probably work but would be very large, and duplicate assemblies that might already exist on the users computer.

yes
i want make my program works without installing .net frame work i want it portable
size of program is not important

Then try it, not sure what I could tell you that isn't in the documentation.

C# is not particulary portable, even if you use Mono on *nix systems. Convert your code to C++ and it will become much more portable... Or at least compilable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.