visual-studio 我可以在 exe(在 Visual Studio 中)中包含 dll 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/476993/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I include dll in exe (in Visual Studio)?
提问by IAdapter
Possible Duplicate:
.NET windows application, can it be compressed into a single .exe?
To run my App I need AxInterop.WMPLib.dlland Interop.WMPLib.dllthat 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?
要运行我需要的应用程序AxInterop.WMPLib.dll,Interop.WMPLib.dll它位于 Debug 和 Release 文件夹中。有什么方法可以将这些 dll 包含到 exe 中,以便我的应用程序仅在一个文件中可用?
回答by Juliet
回答by IAdapter
You can use a tool like boxedapp or thinstall...
您可以使用 boxedapp 或 thinstall 之类的工具...
回答by John Smith
I also recommend boxedapp. It's great app!
我也推荐boxedapp。这是很棒的应用程序!
回答by 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.
不需要额外的实用程序。
回答by cookre
Include them as embedded. You can then extract them at run-time.
包括它们作为嵌入。然后您可以在运行时提取它们。
回答by cookre
For example, add x.dll to the project and set its Build Action to Embedded Resource.
例如,将 x.dll 添加到项目并将其 Build Action 设置为 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();

