I've been trying to figure this out lately. It is working on my Windows machine, where I got SQLite from NuGet, but...
When I put System.Data.SQLite.dll
and SQLite.Interop.dll
straight from my Windows machine into Linux server it says that SQLite.Interop.dll
is not found, but I am sure I see it next right to executable.
Then I tried to compile System.Data.SQLite.dll
with /p:UseInteropDll=false
, but with no luck. This time it says that System.Data.SQLite.dll
is not found.
What is this "not found" mystery?
Use Mono.Data.SQLite.dll
on Linux. Take a look at the Mono manual to using SQLite on Linux or build the System.Data.SQLite.dll on Mono.
You can also map the DLL:
<configuration>
<dllmap dll="sqlite" target="libsqlite.so.0" os="linux"/>
<dllmap dll="sqlite" target="libsqlite.0.dylib" os="osx"/>
<dllmap dll="sqlite3" target="libsqlite3.so.0" os="linux"/>
<dllmap dll="sqlite3" target="libsqlite3.0.dylib" os="osx"/>
</configuration>
No code changes necessary. You can build it yourself.
apt-get install build-essentials unzip
- Download the SQLITE source code - you want the full source code. Currently called sqlite-netFx-full-source-1.0.104.0.zip.
unzip
and cd Source
,
chmod +x
the compile-interop-assembly-release.sh
build shell script, then run it ./compile-interop-assembly-release.sh
. - It'll build an .so
file in the ../bin
directory.
- Copy this
.so
file to the directory that has your application in
- Run your application as normal.
- Note: Ensure that your SQLite database and the directory it's inside of are writable by the user you're trying to run as.
I started the development in Windows, but then moved the application to Mono (Ubuntu 14), which is where the SQLite provider failed to load as OP described.
I had to recompile the System.Data.SQLite.dll using the following command:
MSBuild System.Data.SQLite.2012.csproj /t:Rebuild /p:UseInteropDll=false /p:UseSqliteStandard=true
However, after this I've got the following exception:
The provider did not return a ProviderManifest instance.
Method System.Data.SQLite.UnsafeNativeMethods:GetSettingValue (string,string)' is inaccessible from method
System.Data.SQLite.EF6.SQLiteProviderManifest:GetProviderManifestToken (string)'
To fix this, I had to recompile the System.Data.SQLite.EF6.dll using the following command:
MSBuild System.Data.SQLite.EF6.2012.csproj /t:Rebuild /p:UseInteropDll=false /p:UseSqliteStandard=true
After copying all of the generated files to Mono project's bin directory, everything worked.
The SQLite provider source code version I had used was 1.0.98.1.
Hope this saves someone a lot of time...