We changed from sqlite-net to sqlite.net PCL edition. Our project worked fine with the old one - with the PCL edition, we now have to explicitely declare our platform by using.
var conn = new SQLiteConnection(new SQLitePlatformWin32(), Path.Combine(folderPath, dbName));
But now, when I call this line, we get a
A first chance exception of type 'System.TypeInitializationException' occurred in SQLite.Net.Platform.Win32.dll
Additional information: The type initializer for "SQLite.Net.Platform.Win32.SQLiteApiWin32Internal" threw an exception.
The inner Exception tells us
{"Failed to load native sqlite library"}
Stacktrace:
at SQLite.Net.Platform.Win32.SQLiteApiWin32Internal.sqlite3_open_v2(Byte[] filename, IntPtr& db, Int32 flags, IntPtr zvfs)
at SQLite.Net.Platform.Win32.SQLiteApiWin32.Open(Byte[] filename, IDbHandle& db, Int32 flags, IntPtr zvfs)
at SQLite.Net.SQLiteConnection..ctor(ISQLitePlatform sqlitePlatform, String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks, IBlobSerializer serializer, IDictionary
2 tableMappings, IDictionary
2 extraTypeMappings, IContractResolver resolver)at SQLite.Net.SQLiteConnection..ctor(ISQLitePlatform sqlitePlatform, String databasePath, Boolean storeDateTimeAsTicks, IBlobSerializer serializer, IDictionary
2 tableMappings, IDictionary
2 extraTypeMappings, IContractResolver resolver)
However the sqlite3.dll is in the application folder and it actually did work with the unforked version. I played around with compiling for x86 and x64 and downloaded the latest sqlite3.dll for Win32 but all without success. What are we missing?
I had the same problem in a tests project. Solved it by adding the package http://www.nuget.org/packages/System.Data.SQLite.Core for the SQLitePlatformWin32.
Although not listed as a dependency in the actual version, it was in previous one of the platform's nuget package (http://www.nuget.org/packages/SQLite.Net.Platform.Win32/)
Additionally: in case of using SQLitePlatformGeneric a copy of sqlite3.dll should be placed in the output directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With