C#如何引用资源内的dll我想把引用的dll文件放进exe文件内
单纯的Assembly.Load不行。

解决方案 »

  1.   

    Assembly.LoadFile为何不直接在exe项目中添加引用呢?
      

  2.   

    我想把引用的dll文件放进exe文件内exe项目已添加引用a.dll
    只不过想把a.dll放入exe文件内,单纯Assembly.LoadFile也是不行的FileStream fs = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DevExpress.Data.v11.2.dll", FileMode.Create);
                fs.Write(Properties.Resources.DevExpress_Data_v11_2, 0, Properties.Resources.DevExpress_Data_v11_2.Length);
                fs.Flush();
                fs.Close();
                FileStream fs1 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DevExpress.Printing.v11.2.Core.dll", FileMode.Create);
                fs1.Write(Properties.Resources.DevExpress_Printing_v11_2_Core, 0, Properties.Resources.DevExpress_Printing_v11_2_Core.Length);
                fs1.Flush();
                fs1.Close();
                FileStream fs2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DevExpress.Utils.v11.2.dll", FileMode.Create);
                fs2.Write(Properties.Resources.DevExpress_Utils_v11_2, 0, Properties.Resources.DevExpress_Utils_v11_2.Length);
                fs2.Flush();
                fs2.Close();
                FileStream fs3 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DevExpress.XtraEditors.v11.2.dll", FileMode.Create);
                fs3.Write(Properties.Resources.DevExpress_XtraEditors_v11_2, 0, Properties.Resources.DevExpress_XtraEditors_v11_2.Length);
                fs3.Flush();
                fs3.Close();
                Assembly.LoadFile(System.Windows.Forms.Application.StartupPath + "\\DevExpress.Data.v11.2.dll");
                Assembly.LoadFile(System.Windows.Forms.Application.StartupPath + "\\DevExpress.Printing.v11.2.Core.dll");
                Assembly.LoadFile(System.Windows.Forms.Application.StartupPath + "\\DevExpress.Utils.v11.2.dll");
                Assembly.LoadFile(System.Windows.Forms.Application.StartupPath + "\\DevExpress.XtraEditors.v11.2.dll");
      

  3.   

    好像没有太简单的方法, 参考这篇文章:
    Embed an Assembly as a Resource
    http://www.codeproject.com/Articles/56197/Embed-an-Assembly-as-a-Resource
      

  4.   

    试一试这个工具:ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly. It works on executables and DLLs alike and comes with several options for controlling the processing and format of the output. See the accompanying documentation for details.http://www.microsoft.com/en-us/download/details.aspx?id=17630
      

  5.   

    只是个操作的问题啊,牵扯不到代码。
    参考一下下面这个链接。
    http://hi.baidu.com/ifcat/item/44e3b6af549d443f020a4d5d
      

  6.   

    在解决方案里面的引用-》右键->添加引用->浏览-》找到你的.dll
      

  7.   

    没用过,这个要是能实现,就太强大了,所有调用的dll全部隐藏起来了
      

  8.   

    在网上找一个工具spoon ,用起来挺好的。ILMerge 这个工具不会用啊,用一下出错一下,汗