CodesLikeA_Mokey CodesLikeA_Mokey - 1 month ago 20
C# Question

C# sqlite Unable to load sqlite3.dll

I have used nuget to install

sqlite-net
and
System.Data.SQLite (x86/x64)
. I have rebuilt and I have restarted and I still get the following error:
Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
. This is the line that triggers it:

db = new SQLiteConnection("Data Source=C:\\Users\\xxxxxxx\\Desktop\\mydb.sqlite;Version=3;");


Am I missing something? Shouldn't this just work?

Answer

I think it could be an architecture mismatch between your application and the sqlite driver.

Download a precompiled binary package matching your architecture here http://sqlite.org/download.html and place the .dll into the bin\Debug or bin\Release folder. I think it could probably be an architecture mismatch between x86 and x64.

From documentation you can see the needed deployment structure:

<bin>\App.exe (optional, managed-only application executable assembly)
<bin>\App.dll (optional, managed-only application library assembly)
<bin>\System.Data.SQLite.dll (required, managed-only core assembly)
<bin>\System.Data.SQLite.Linq.dll (optional, managed-only LINQ assembly)
<bin>\System.Data.SQLite.EF6.dll (optional, managed-only EF6 assembly)
<bin>\x86\SQLite.Interop.dll (required, x86 native interop assembly)
<bin>\x64\SQLite.Interop.dll (required, x64 native interop assembly)
Comments