文件名称:将DLL嵌入到EXE大众
文件大小:1.26MB
文件格式:ZIP
更新时间:2020-06-08 04:39:00
嵌入资源 包含dll
将dll动态库嵌入到exe当中,无需嵌入互操作类型 1、双击Resources.resx 2、添加现有文件 3、添加代码 public Form1() { //添加程序解析失败事件 AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);//添加代码 InitializeComponent(); JObject obj = new JObject(); } //添加代码 System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { string dllName = args.Name.Contains(",") ? args.Name.Substring(0, args.Name.IndexOf(',')) : args.Name.Replace(".dll", ""); dllName = dllName.Replace(".", "_"); if (dllName.EndsWith("_resources")) return null; System.Resources.ResourceManager rm = new System.Resources.ResourceManager(GetType().Namespace + ".Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); byte[] bytes = (byte[])rm.GetObject(dllName); return System.Reflection.Assembly.Load(bytes); }
【文件预览】:
C#将DLL嵌入到exe当中
----双击Resources.resx.JPG(31KB)
----捕获.JPG(82KB)
----添加现有文件.png(160KB)
----WindowsFormsApplication1()
--------.vs()
--------WindowsFormsApplication1()
--------WindowsFormsApplication1.sln(1KB)