Saturday 20 August 2016

System.Data.Sqlite for Linux / Ubuntu / Mono

System.Data.Sqlite default Nuget package will not work in Ubuntu / Mono.
This error will occur:

System.TypeInitializationException: The type initializer for 'System.Data.SQLite.SQLiteFactory' threw an exception. ---> System.DllNotFoundException: SQLite.Interop.dll  at (wrapper managed-to-native) System.Data.SQLite.UnsafeNativeMethods:sqlite3_config_none (System.Data.SQLite.SQLiteConfigOpsEnum)  at System.Data.SQLite.SQLite3.StaticIsInitialized () <0x4037a6f0 0x00087=""> in :0   at System.Data.SQLite.SQLiteLog.Initialize () <0x4037a370 0x00027=""> in :0   at System.Data.SQLite.SQLiteFactory..cctor () <0x403645f0 0x00057=""> in :0   --- End of inner exception stack trace ---


copying over SQLite.Interop.dll to the bin folder didn't fix the issue.
the solution is to download Sqlite source code and build it yourself using this command:
MSBuild System.Data.SQLite.2012.csproj /t:Rebuild /p:UseInteropDll=false /p:UseSqliteStandard=true

here is a download link to save you time: