vendredi 21 août 2015

C# Release build can't load SQLite.Interop.dll

I'm building a c# program that uses a local SQLite database to manage some simple data.

I am using the NuGet System.Data.SQLite (x64/x86) v1.0.98.0 - downloaded using the package manager console in Visual Studio Community 2015. Windows 7 64-bit.

I've built and debugged my code using the "Any CPU", x64, and x86 settings and it works fine. After I publish any of these versions though, I get the following error:

An unhandled exception of type 'System.DllNotFoundException' occurred in System.Data.SQLite.dll
Additional information: Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

The error occurs here:

SQLiteConnection.CreateFile("local-db.sqlite");
sqlite = new SQLiteConnection("Data Source=local-db.sqlite;Version=3;"); //Error on this line

Suggestions that haven't worked:

  • copying the bin/debug/x64 (and x86) folders (They contain versions of Interop.dll) up one directory
  • add SQLite.Interop.dll as a project reference (error - can't add as a reference)
  • copying the most recent version of Interop.dll to the System.Data.SQLite directory (the directory referenced by my project)

At the very least, it's not failing to load the .dll but failing to find it. Does anyone have a fix for this? There are a handful of related questions but they are either unanswered or don't work for me.

Aucun commentaire:

Enregistrer un commentaire