我可以在EXE DLL(在Visual Studio)? [重复]
-
20-08-2019 - |
题
<强>可能重复:强>结果 .NET Windows应用程序,它可以被压缩成单个.exe?
要运行我的应用程序,我需要AxInterop.WMPLib.dll
和位于调试和发布文件夹Interop.WMPLib.dll
。有没有什么办法,包括这些dll成exe所以我的应用程序在一个文件只适用?
解决方案
只要你的DLL是.NET组件,然后 ILMerge 一>应该能够将您的exe文件和所有的依赖合并成一个单一的文件。
其他提示
您可以像使用boxedapp工具或thinstall ...
我还建议boxedapp。这是伟大的应用程序!
包含它们作为嵌入。然后,您可以在运行时提取它们。
是的,我离开了代码写入文件了...
FileStream so=new FileStream("c:\\\wherever\\\x.dll",FileMode.Create);
so.Write(buf,0,ssize);
so.Close();
不需要额外的工具。
例如,添加x.dll到项目,并设置其生成操作为嵌入的资源。
要提取:
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();
不隶属于 StackOverflow