Wierd sqlite-net pcl issue

So i made a expense tracking app and now im hooking it up to a sqlite database, but when i try to text it, it throws wierd errors:
System.TypeInitializationException: „Inicjator typów zgłosił wyjątek dla typu 'Spending.Services.DatabaseService'.”
System.TypeInitializationException: „Inicjator typów zgłosił wyjątek dla typu 'Spending.Services.DatabaseService'.”
with 3 internal errors:
AggregateException: Wystąpił przynajmniej jeden błąd.

TypeInitializationException: Inicjator typów zgłosił wyjątek dla typu 'SQLite.SQLiteConnection'.

Exception: Library e_sqlite3 not found
plat: win
suffix: DLL
possibilities (2):
1) D:\C#\Spending\bin\Debug\runtimes\win-x86\native\e_sqlite3.dll
2) D:\C#\Spending\bin\Debug\e_sqlite3.dll
win TryLoad: D:\C#\Spending\bin\Debug\runtimes\win-x86\native\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): Nie można odnaleźć określonego modułu
w SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
win TryLoad: D:\C#\Spending\bin\Debug\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): Nie można odnaleźć określonego modułu
w SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
NOT FOUND
AggregateException: Wystąpił przynajmniej jeden błąd.

TypeInitializationException: Inicjator typów zgłosił wyjątek dla typu 'SQLite.SQLiteConnection'.

Exception: Library e_sqlite3 not found
plat: win
suffix: DLL
possibilities (2):
1) D:\C#\Spending\bin\Debug\runtimes\win-x86\native\e_sqlite3.dll
2) D:\C#\Spending\bin\Debug\e_sqlite3.dll
win TryLoad: D:\C#\Spending\bin\Debug\runtimes\win-x86\native\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): Nie można odnaleźć określonego modułu
w SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
win TryLoad: D:\C#\Spending\bin\Debug\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): Nie można odnaleźć określonego modułu
w SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
NOT FOUND
38 Replies
Mąż Zuzanny Harmider Szczęście
to translate from polish: error:
System.TypeInitializationException: "Type initiator threw an exception for type 'Spending.Services.DatabaseService'"
System.TypeInitializationException: "Type initiator threw an exception for type 'Spending.Services.DatabaseService'"
internal errors:
1. AggregateException: At least one error had occured.

2. TypeInitializationException: Type initializator threw an exception for type 'SQLite.SQLiteConnection'.

3. its in english so no need to translate
1. AggregateException: At least one error had occured.

2. TypeInitializationException: Type initializator threw an exception for type 'SQLite.SQLiteConnection'.

3. its in english so no need to translate
reflectronic
reflectronic4mo ago
i would try using Microsoft.Data.Sqlite instead
Mąż Zuzanny Harmider Szczęście
is the library broken?
reflectronic
reflectronic4mo ago
no, it just doesn't come with the native sqlite library it also looks to be unmaintained
Mąż Zuzanny Harmider Szczęście
i just need it for a simple expense app for myself what do i do to make the library work, do i just provide the ddl?
reflectronic
reflectronic4mo ago
oh, i see, sqlite-net-pcl, not sqlite-net
reflectronic
reflectronic4mo ago
it is probably still easierto use Microsoft.Data.Sqlite instead of debugging this problem
Mąż Zuzanny Harmider Szczęście
ill try manually inserting the ddl first
reflectronic
reflectronic4mo ago
i would not try that
reflectronic
reflectronic4mo ago
because it is only going to cause you problems in the future
Trinitek
Trinitek4mo ago
what nuget package are you using here exactly?
Mąż Zuzanny Harmider Szczęście
sqlite-net-pcl 1.9.172
SQLite-net is an open source and light weight library providing easy SQLite database storage for .NET, Mono, and Xamarin applications. This version uses SQLitePCLRaw to provide platform independent versions of SQLite.
reflectronic
reflectronic4mo ago
because changing your application to release mode, or building it for a certain architecture, or just deleting your bin folder and rebuilding, will break your application and you will have to copy it again
reflectronic
reflectronic4mo ago
it will take you no more than five minutes to try using Microsoft.Data.Sqlite instead
Mąż Zuzanny Harmider Szczęście
is using that package also as easy as sqlite-net-pcl?
Trinitek
Trinitek4mo ago
given the issues you've had so far, I'd say yes
Mąż Zuzanny Harmider Szczęście
what i like in the current package is that i cant just work on objects and dont have to write sql queries? does the msc.data.sqlite package require me to write sql queries? coz i hate it
Trinitek
Trinitek4mo ago
around here we'd typically recommend EF Core with the accompanying SQLite package (which uses Microsoft.Data.SQLite) to do the same thing
Trinitek
Trinitek4mo ago
https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Sqlite/10.0.0-preview.6.25358.103 that's going to give you C# objects and the ability to write LINQ queries on your tables, so you're not writing sql queries I don't think anyone around here has any experience with sqlite-net-pcl
reflectronic
reflectronic4mo ago
yes if you are using the custom ORM stuff in sqlite-net-pcl it will take more than five minutes. well, i didn't know that was a thing. sorry
reflectronic
reflectronic4mo ago
they have a good example here which uses sqlite
Mąż Zuzanny Harmider Szczęście
i moved to the library u said and the error persists
reflectronic
reflectronic4mo ago
can you send your csproj file
Mąż Zuzanny Harmider Szczęście
@reflectronic
reflectronic
reflectronic4mo ago
ok. is there a reason you used .NET Framework
Mąż Zuzanny Harmider Szczęście
i used it coz that's what i was tought it worked fine before i made like 5 projects on the same setup and the sqlite worked fine i had to move vs to a new disc coz i didnt have a lot of space on c: tho, maybe i did something wrong on setup?
reflectronic
reflectronic4mo ago
right click on the packages.config file in Visual Studio and pick "Migrate to PackageReference"
Mąż Zuzanny Harmider Szczęście
and then what?
reflectronic
reflectronic4mo ago
and then it will work

Did you find this page helpful?