How to merge multiple assemblies into one?

Arun Rana picture Arun Rana · Nov 10, 2011 · Viewed 87.2k times · Source

I consuming my service stack using EXE project (startup task for azure application) in that I have copied following service stack's DLL & some Azure's DLLs in to EXE project.

dlls

When I build this EXE project then Azure DLLs will be bundled with my EXE but service stack's DLL will not be bundled with EXE, because to run my EXE on any machine I need to copy all service stack's DLL manually.

I have used this service stack's dll to use

JsonServiceClient client = new JsonServiceClient(servicepath);

What should I have to do to bundled all these DLLs in to my EXE?

Answer

Yahia picture Yahia · Nov 10, 2011

You have several options:

OR

  • use some tool like SmartAssembly (commercial)
    it can embed and merge among other things (no need to change your source code)

OR

  • code that yourself in less than 10 lines (free but minimal source code change)
    mark all needed dependencies as "embedded resource" - this way they are included in the EXE file... you need to setup an AssemblyResolve handler which at runtime reads from Resources and returns the needed DLLs to the .NET runtime...