Can I include dll in exe (in Visual Studio)? [dupl

2019-01-11 07:48发布

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?

6条回答
手持菜刀,她持情操
2楼-- · 2019-01-11 08:11

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.

查看更多
Viruses.
3楼-- · 2019-01-11 08:12

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.

查看更多
做个烂人
4楼-- · 2019-01-11 08:13

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

查看更多
ら.Afraid
5楼-- · 2019-01-11 08:15

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

查看更多
倾城 Initia
6楼-- · 2019-01-11 08:15

I also recommend boxedapp. It's great app!

查看更多
仙女界的扛把子
7楼-- · 2019-01-11 08:28

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();
查看更多
登录 后发表回答