• C#中将DLL文件打包到EXE文件


    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());
            }
        }
  • 相关阅读:
    things to analysis
    retrieve jenkins console output
    temp
    temp
    mysql on Mac OS
    Scala的几个小tips
    docker查看容器使用率
    JVM性能监控(jconsole和jvisualvm)
    线程死锁问题
    线程阻塞状态
  • 原文地址:https://www.cnblogs.com/yshyee/p/7978566.html
Copyright © 2020-2023  润新知