Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#嵌入资源dll_C#_Sqlite_Dll - Fatal编程技术网

c#嵌入资源dll

c#嵌入资源dll,c#,sqlite,dll,C#,Sqlite,Dll,我有一个需要dll资源的函数 using (SQLiteConnection c = new SQLiteConnection("Data Source=logindata;Version=3;")) { } 它需要:SQLite.Interop.dll 因此,我没有将dll放在同一个Environment文件夹中,而是将其用作嵌入式资源: [STAThread] static void Main() { A

我有一个需要dll资源的函数

    using (SQLiteConnection c = new SQLiteConnection("Data Source=logindata;Version=3;"))
    {
    }
它需要:SQLite.Interop.dll

因此,我没有将dll放在同一个Environment文件夹中,而是将其用作嵌入式资源:

   [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            Application.Run(new Form1());
        }

        private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EmbedAssembly.SQLite.Interop.dll"))
            {
                byte[] Data = new byte[stream.Length];
                stream.Read(Data, 0, Data.Length);
                return Assembly.Load(Data);

            }
        }
但它仍然抛出一个异常:

Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

编辑:通过将整个新类添加到项目中而不是将其作为dll引用来解决

通过将整个新Sqlite类添加到我的项目中而不是将其添加到我的项目中作为引用来解决。

通过将整个新Sqlite类添加到我的项目中而不是将其作为dll引用添加到我的项目中来解决参考资料