The type initializer for 'SQLite.SQLiteConnection' threw an exception
I have in my PCL service this package installed from nuget. Service is referenced in a windows phone 8.1 app project and android app project. In android app, everything works fine, but in winphone app, i'm getting an error
{"The type initializer for 'SQLite.SQLiteConnection' threw an exception."}
with innerException
{"Unable to load DLL 'esqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}
when i try to create database with:
var connection = new SQLiteConnection(path);
Path is:
"C:\\Data\\Users\\DefApps\\APPDATA\\Local\\Packages\\d97e146f-c80d-4061-ab67-2fcf5d035388_a1691p6wrfp9c\\LocalState\\db_sqlnet.db"
I have tried to install "SQLitePCL.native.sqlite3.v120_wp81" package that contain dll in PCL project, but it won't install.
Can someone help with this?
Which kind of Windows Phone 8.1? Silverlight or RT?
WP 8.1 universal app... Error appears on both, VS emulator and physical lumia 520 device.
having a problem along the same lines...spent a few hours trying to figure it out. the library versions are the same.
[0:] System.TypeInitializationException: The type initializer for 'SQLite.SQLiteConnection' threw an exception. ---> System.MissingMethodException: Method 'raw.SetProvider' not found. at SQLite.SQLiteConnection..cctor () [0x00000] in /Users/fak/Dropbox/Projects/sqlite-net/src/SQLite.cs:171 --- End of inner exception stack trace ---
PCL library <package id="sqlite-net-pcl" version="1.1.2" <package id="SQLitePCL.bundle_green" version="0.9.2" <package id="SQLitePCL.raw_basic" version="0.8.6"
Droid Library <package id="sqlite-net-pcl" version="1.1.2" <package id="SQLitePCL.bundle_green" version="0.9.2" <package id="SQLitePCL.plugin.sqlite3.android" version="0.9.2" <package id="SQLitePCL.raw_basic" version="0.8.6"
I've tried cleaning and deleting obj/bin folders, etc.
Any help would be appreciated
You should not have the raw_basic package. If it was there from previous versions, remove it. If it was brought in by bundle_green, that's a bug.
OTOH, you should have SQLitePCL.raw (note the lack of _basic in the id).
thank you for the very rapid response. i did that before coming back and now feel like the jerk that i am.
thank you very much for such a rapid response (no sarcasm)
You are clearly very careful about doing your homework before asking for help, which is great. Thanks.
But nothing here in this thread suggests you are a jerk. :-)
Hello. I'm having the same issue when running Nunit tests on OSX, it works properly on Windows.
The tests are in a C# library and the packages are :
<package id="sqlite-net-pcl" version="1.1.2" targetFramework="net45" />
<package id="SQLitePCL.bundle_green" version="0.9.2" targetFramework="net45" />
<package id="SQLitePCL.native.sqlite3.v110_xp" version="0.9.2" targetFramework="net45" />
<package id="SQLitePCL.plugin.sqlite3.net45" version="0.9.2" targetFramework="net45" />
<package id="SQLitePCL.raw" version="0.9.2" targetFramework="net45" />
It can't find any esqlite3.
System.TypeInitializationException : The type initializer for 'SQLite.SQLiteConnection' threw an exception.
----> System.DllNotFoundException : esqlite3
Looking at mono errors:
Mono: DllImport error loading library '/Library/Frameworks/Mono.framework/lib/libesqlite3': 'dlopen(/Library/Frameworks/Mono.framework/lib/libesqlite3, 9): image not found'.
Mono: DllImport error loading library '/Library/Frameworks/Mono.framework/lib/libesqlite3.dylib': 'dlopen(/Library/Frameworks/Mono.framework/lib/libesqlite3.dylib, 9): image not found'.
Mono: DllImport error loading library '/Library/Frameworks/Mono.framework/lib/libesqlite3.so': 'dlopen(/Library/Frameworks/Mono.framework/lib/libesqlite3.so, 9): image not found'.
Mono: DllImport error loading library '/Library/Frameworks/Mono.framework/lib/libesqlite3.bundle': 'dlopen(/Library/Frameworks/Mono.framework/lib/libesqlite3.bundle, 9): image not found'.
Mono: DllImport error loading library '/Library/Frameworks/Mono.framework/Libraries/libesqlite3': 'dlopen(/Library/Frameworks/Mono.framework/Libraries/libesqlite3, 9): image not found'.
Mono: DllImport error loading library '/Library/Frameworks/Mono.framework/Libraries/libesqlite3.dylib': 'dlopen(/Library/Frameworks/Mono.framework/Libraries/libesqlite3.dylib, 9): image not found'.
Mono: DllImport error loading library '/Library/Frameworks/Mono.framework/Libraries/libesqlite3.so': 'dlopen(/Library/Frameworks/Mono.framework/Libraries/libesqlite3.so, 9): image not found'.
Mono: DllImport error loading library '/Library/Frameworks/Mono.framework/Libraries/libesqlite3.bundle': 'dlopen(/Library/Frameworks/Mono.framework/Libraries/libesqlite3.bundle, 9): image not found'.
Mono: DllImport error loading library 'libesqlite3': 'dlopen(libesqlite3, 9): image not found'.
Mono: DllImport error loading library 'libesqlite3.dylib': 'dlopen(libesqlite3.dylib, 9): image not found'.
Mono: DllImport error loading library 'libesqlite3.so': 'dlopen(libesqlite3.so, 9): image not found'.
Mono: DllImport error loading library 'libesqlite3.bundle': 'dlopen(libesqlite3.bundle, 9): image not found'.
Mono: DllImport error loading library 'esqlite3': 'dlopen(esqlite3, 9): image not found'.
On these folders, I only have libsqlite3 files, not libesqlite3.
Creating a libesqlite3 link from libsqlite3 solves this but it's doesn't feel like the solution. Could someone help with this ? Am I missing something ?
Er, that's a problem.
The default settings here do not currently support Mono on Mac OS.
For 'net45' I currently assume Windows desktop, so that people don't have to add an extra nuget package, but it also means Mac/Linux won't work. I could probably fix this with some nuget 3.x magic, but I'm not certain, and I haven't switched anything to nuget 3.x yet because I'm not sure what'll break.
In other words, to give Windows users a "batteries included" experience where things "just work", I intentionally broke Mono on Mac/Linux. :-(
I've got an idea for how I might be able to fix this. Not sure if it'll work or not.
For now, let's get an opinion from @praeclarum :
Which of the following two problems would you prefer that we have?
- sqlite-net-pcl doesn't support Mono on Mac/Linux
- Everybody using sqlite-net-pcl on Windows desktop needs to manually add a sqlite dll somehow (and there are a couple of different options for how we can expect this to be done).
I'm having the same error on Win10 Education version:
The type initializer for 'SQLite.SQLiteConnection' threw an exception.
Can't load the DLL: esqlite3
I have the following packages in the PCL project:
<package id="sqlite-net-pcl" version="1.1.2" targetFramework="portable45-net45+win8+wpa81" />
<package id="SQLitePCL.bundle_green" version="0.9.3" targetFramework="portable45-net45+win8+wpa81" />
<package id="SQLitePCL.raw" version="0.9.3" targetFramework="portable45-net45+win8+wpa81" />
And these for the Win project:
<package id="sqlite-net-pcl" version="1.1.2" targetFramework="win81" />
<package id="SQLitePCL.bundle_green" version="0.9.3" targetFramework="win81" />
<package id="SQLitePCL.native.sqlite3.v120" version="0.9.3" targetFramework="win81" />
<package id="SQLitePCL.plugin.sqlite3.win81" version="0.9.3" targetFramework="win81" />
<package id="SQLitePCL.raw" version="0.9.3" targetFramework="win81" />
I guess i'm doing something wrong, but I can't find what..
Thanks a lot!
My first suggestion would be for you to upgrade your packages. sqlite-net-pcl should be at 1.2. After that, you'll get some dependent packages that start with SQLitePCLRaw.* -- keep those, but remove the ones that start with SQLitePCL.*.
I have the same issue. I have following packages in PCL project
<package id="sqlite-net-pcl" version="1.2.1" targetFramework="portable45-net45+win8+wpa81" />
<package id="SQLitePCLRaw.bundle_green" version="1.1.0" targetFramework="portable45-net45+win8+wpa81" />
<package id="SQLitePCLRaw.core" version="1.1.0" targetFramework="portable45-net45+win8+wpa81" />
and these in Win project
<package id="sqlite-net-pcl" version="1.2.1" targetFramework="net45" />
<package id="SQLitePCLRaw.bundle_green" version="1.1.0" targetFramework="net45" />
<package id="SQLitePCLRaw.core" version="1.1.0" targetFramework="net45" />
<package id="SQLitePCLRaw.lib.e_sqlite3.linux" version="1.1.0" targetFramework="net45" />
<package id="SQLitePCLRaw.lib.e_sqlite3.osx" version="1.1.0" targetFramework="net45" />
<package id="SQLitePCLRaw.lib.e_sqlite3.v110_xp" version="1.1.0" targetFramework="net45" />
<package id="SQLitePCLRaw.provider.e_sqlite3.net45" version="1.1.0" targetFramework="net45" />
@Alhantro You have the same issue as which one? There are several here. Please post details and specifics.
@ericsink I'm sorry, i solved the problem.
No worries. Thanks.