C#中将DLL文件打包到EXE文件
标签:pre exec using 复制 oid 增加 ring [] name
1:在工程目录增加dll目录,然后将dll文件复制到此目录,例如:
2:增加引用,定位到工程的dll目录,选中要增加的dll文件
3:修改dll文件夹下面的dll文件属性
选中嵌入式资源,不复制。
4:增加dll加载代码
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
string resourceName = "openie01.dll" + new AssemblyName(args.Name).Name + ".dll";
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
{
Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);
}
};
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
C#中将DLL文件打包到EXE文件
标签:pre exec using 复制 oid 增加 ring [] name
原文地址:http://www.cnblogs.com/yshyee/p/7978566.html
评论