Click here to Skip to main content
15,029,369 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a C# desktop program. In my project there are some sub projects and its final output are several .exe files and many DLLs. So how can I combine all my programs into one .exe file? :sigh::cool:
Posted
Updated 20-Jan-11 7:03am
v3
Comments
Sergey Alexandrovich Kryukov 20-Jan-11 13:04pm
   
You can do it, but I wonder why?

You can merge them with ILMerge.

http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx[^]

Here's the doanload page:

http://msdn.microsoft.com/en-us/netframework/aa569269[^]

Here's a CodeProject article about it:

Merging .NET assemblies using ILMerge[^]
   
v2
Comments
Sergey Alexandrovich Kryukov 20-Jan-11 13:03pm
   
Good reference, thank you - a 5.
Manfred Rudolf Bihy 20-Jan-11 13:05pm
   
Thanks and 5+ from me too. I was just about to put this off as a silly question even though I still don't get it why OP would want to do it.
#realJSOP 20-Jan-11 13:15pm
   
One reason is maintenance updates. Instead of having click-once check a crapload of files, it only has to check one. Another reason is convenience - all of the files associated with the application are tucked nice and neat into a single executable, resulting in no problems with version mismatches.
Manfred Rudolf Bihy 20-Jan-11 14:06pm
   
Ok I can understand that, but OP said apart from the DLLs there also were several executables to cram in too. How would they get called? I always thought an exe file only has one entry point (main). That is the part I can't wrap my mind about.
#realJSOP 12-Mar-11 11:38am
   
Well, if the executables each used one or more of the DLLs, they could be merged into the EXE. He'd still have multiple EXE's, but he wouldn't have any DLLs. This also means that the total combined size of the multiple EXE's may be a bit larger because each DLL that's merged would be merged into the exe that uses it.
Manfred Rudolf Bihy 14-Mar-11 6:10am
   
Thanks for coming back to this. So you're actually saying OP's requirement "So how can I combine all my programs into one .exe file" is not really reachable?
I've heard of people wanting to combine 1 exe + several DLLs into a single exe. But you have multiple exes. Why would you want to combine them into a single exe? What would that achieve?

If deployment is your problem, there are so many solutions to that.

Alternatively, since you own all the source code, just move everything into a single project. You probably won't even have to change any code (except maybe tweak the namespaces around a little).
   
v2
Comments
#realJSOP 20-Jan-11 13:12pm
   
Technically (and you already know this), he can add references to any .Net assembly (including EXEs). I think he may have slightly mis-stated his requirements.
Nish Nishant 20-Jan-11 13:14pm
   
Yeah, I get that, but I am not sure he wants to do this for the "right" reasons.
#realJSOP 20-Jan-11 16:16pm
   
We can only guess at what he really wants to do and the reasons for it. :)
Sergey Alexandrovich Kryukov 20-Jan-11 15:11pm
   
I also have the same doubts.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900