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

允我心安 提交于 2019-11-27 13:19:40

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.

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

I also recommend boxedapp. It's great app!

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

cookre

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.

cookre

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();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!