CodesLikeA_Mokey CodesLikeA_Mokey - 1 year ago 233
C# Question

C# sqlite Unable to load sqlite3.dll

I have used nuget to install

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 Source

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

Download a precompiled binary package matching your architecture here 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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download