args) = { string resourceName = " openie01.dll " + new Asse

时间:2022-05-29 08:25:24

1:在工程目录增加dll目录,然后将dll文件复制到此目录,例如:

args) = { string resourceName = " openie01.dll " + new Asse

2:增加引用,定位到工程的dll目录,,选中要增加的dll文件

args) = { string resourceName = " openie01.dll " + new Asse

3:改削dll文件夹下面的dll文件属性

args) = { string resourceName = " openie01.dll " + new Asse

选中嵌入式资源,不复制。

args) = { string resourceName = " openie01.dll " + new Asse

4:增加dll加载代码

static class Program { /// <summary> /// The main entry point for the application. /// </summary> [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()); } }