Why am I getting a DllNotFoundException when adding a SQLite Nuget package to LINQPad?

I added the System.Data.SQLite.Core NuGet package to my LINQPad 5 (Premium) query, and then try to do the following:

 new SQLiteConnection(":memory:").Dump(); 

But I get:

DllNotFoundException: Unable to load the SQLite.Interop.dll DLL file: The specified module was not found. (Exception from HRESULT: 0x8007007e)

How can I find out LINQPad where to find SQLite Native DLL?

Please note: I do not want to use the IQ driver.

+6
source share
2 answers

This library is not mentioned in the standard way because it is native and requires different images for X86 and X64.

The workaround in LINQPad is to find the following folder:

 %localappdata%\LINQPad\NuGet.FW46\System.Data.SQLite.Core\System.Data.SQLite.Core.1.0.99.0\build\net46 

and copy the X86 and X64 subfolders to the folder where LINQPad.exe is located.

+9
source

Another solution based on this comment on the LINQPad forum should do the following:

  • Copy the System.Data.SQLite.dll file (and possibly also the corresponding System.Data.SQLite.xml file) somewhere, for example. in the same directory as your LINQPad request file.
  • Copy the x64 and x86 subdirectories, for example. from the C: \ Users \ your-user-name-go-here \ AppData \ Local \ LINQPad \ NuGet.FW46 \ System.Data.SQLite \ System.Data.SQLite.Core.1.0.103 \ build \ net46 directory, in the same directory that you copied the file in step [1].
  • Add the following code to your LINQPad query:

     System.Environment.SetEnvironmentVariable( "PreLoadSQLite_BaseDirectory", @"C:\path\to\which\you\copied\the\files\and\directories\in\steps\one\and\two"); 

The advantage of this relative to the answer provided by Joe Albahari (creator of LINQPad by-the-way!) Is that it could easily be included in the Git repository (you would have to store your LINQPad request this way).

+3
source

All Articles