1:在工程目录增加dll目录,然后将dll文件复制到此目录,例如:
2:增加引用,定位到工程的dll目录,选中要增加的dll文件
3:修改dll文件夹下面的dll文件属性
选中嵌入式资源,不复制。
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()); } }
时间: 2024-11-14 13:18:23