12

Possible Duplicate:
.NET windows application, can it be compressed into a single .exe?

To run my App I need AxInterop.WMPLib.dll and Interop.WMPLib.dll that are located in Debug and Release folder. Is there any way to include those dlls into exe so my app is available in one file only?

Community
  • 1
  • 1
IAdapter
  • 62,595
  • 73
  • 179
  • 242
  • Even though this is possible I don't really like it. The point of shared libraries is that they are shared between programs. What about downloading them when your program discovers they are not already installed? – Tim Matthews Jan 25 '09 at 02:07

6 Answers6

19

As long as your DLLs are .NET assemblies, then ILMerge should be able to combine your exe and all of its dependencies into a single file.

Juliet
  • 80,494
  • 45
  • 196
  • 228
  • 1
    This is noted on the ILMerge page as well but for WPF apps use this: http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx – Menefee Jul 26 '12 at 17:51
4

I also recommend boxedapp. It's great app!

John Smith
  • 4,111
  • 1
  • 15
  • 15
4

You can use a tool like boxedapp or thinstall...

0

Include them as embedded. You can then extract them at run-time.

cookre
  • 705
  • 1
  • 5
  • 7
0

Yes, I left out the code to write the file out...

FileStream so=new FileStream("c:\\\wherever\\\x.dll",FileMode.Create);

so.Write(buf,0,ssize);

so.Close();

No extra utilities required.

nawfal
  • 70,104
  • 56
  • 326
  • 368
cookre
  • 705
  • 1
  • 5
  • 7
-2

For example, add x.dll to the project and set its Build Action to Embedded Resource.

To extract:

 string AppPath=Assembly.GetExecutingAssembly().Location;
 Assembly ThisAssembly=Assembly.LoadFrom(AppPath);
 System.IO.Stream fs=ThisAssembly.GetManifestResourceStream("yourproectname.x.dll");
 int ssize=(int)fs.Length;
 byte [] buf=new byte[ssize];
 fs.Read(buf,0,ssize);
 fs.Close();
shoosh
  • 76,898
  • 55
  • 205
  • 325
cookre
  • 705
  • 1
  • 5
  • 7
  • 2
    The first two lines are an unnecessary complication of "Assembly thisAssembly =Assembly.GetExecutingAssembly();". Then there is this line missing at the end: "Assembly.Load(buf);". Finally, this is a horrible solution because you can then access the loaded assembly through reflection only. – Wim Coenen Jan 25 '09 at 02:23