c#嵌入资源dll
我有一个需要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
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引用添加到我的项目中来解决参考资料