ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

'Library e_sqlite3 not found for WPF app for .NET 4.7.2 #537

Closed Vechkanov closed 1 year ago

Vechkanov commented 1 year ago

I am facing System.Exception: 'Library e_sqlite3 not found for .NET 4.7.2, when I init sqlite, by calling SQLitePCL.Batteries_V2.Init().

For testing I create sample empty project where I only have SQLitePCL dependencies and the only thing that project does - is initialise sqlite. The problem looks like fixed by downloading sqlite.dll from sqlite website, renaming to e_sqlite.dll and adding to the project. But I am not sure that this will not cause future problems.

What version of SQLitePCLRaw are you using? 2.1.4 (latest)

If you are using one of the SQLitePCLRaw bundle packages, which one? bundle_green

What platform are you running on? What operating system? Which version? What CPU? Windows 10 Enterprise 22H2 (OS build 19045.2486) x64 CPU Intel(R) Core(TM) i5-10400H CPU @ 2.60GHz 2.59 GHz

What target framework are you building for? I am building WPF App

Are you on .NET Framework or the newer stuff (.NET Core, .NET 5+, etc)? . NetFramework 4.7.2

Are you using the command line, or an IDE? Which IDE? Which version of that IDE? Microsoft Visual Studio Enterprise 2022 (64-bit) Version 17.4.4

What is the exact error message you are seeing when the problem happens? System.Exception HResult=0x80131500 Message=Library e_sqlite3 not found plat: win suffix: DLL possibilities (2): 1) C:\Users\v-vvechkanov\source\repos\TestSqliteWPF\TestSqliteWPF\bin\Debug\runtimes\win-x86\native\e_sqlite3.dll 2) C:\Users\v-vvechkanov\source\repos\TestSqliteWPF\TestSqliteWPF\bin\Debug\e_sqlite3.dll win TryLoad: C:\Users\v-vvechkanov\source\repos\TestSqliteWPF\TestSqliteWPF\bin\Debug\runtimes\win-x86\native\e_sqlite3.dll thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action1 log, IntPtr& h) win TryLoad: C:\Users\v-vvechkanov\source\repos\TestSqliteWPF\TestSqliteWPF\bin\Debug\e_sqlite3.dll thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action1 log, IntPtr& h) NOT FOUND

Source=SQLitePCLRaw.batteries_v2 StackTrace: at SQLitePCL.NativeLibrary.Load(String libraryName, Assembly assy, Int32 flags) at SQLitePCL.Batteries_V2.MakeDynamic(String name, Int32 flags) at SQLitePCL.Batteries_V2.DoDynamic_cdecl(String name, Int32 flags) at SQLitePCL.Batteries_V2.Init() at TestSqliteWPF.App..ctor() in C:\Users\v-vvechkanov\source\repos\TestSqliteWPF\TestSqliteWPF\App.xaml.cs:line 18 at TestSqliteWPF.App.Main()

Sometimes other packages using SQLitePCLRaw cause problems when they are mixed together. What other packages are you including in your project? Only dependencies for bundle_green: core, e_sqlite3, dynamic_cdecl

How can we reproduce the problem you are seeing? Your issue will get attention much faster if you attach a minimal reproduction sample project. Here is a simple project where my problem can be reproduced. Just download it, compile and launch. https://github.com/Vechkanov/TestSqliteWPF

ericsink commented 1 year ago

Thanks for including a repro sample project.

To confirm, I can reproduce the problem with your sample.

Now try this:

Remove your build folders (bin and obj), to make sure everything is clean.

In Visual Studio, right-click on the packages.config file, and choose "Migrate packages.config to PackageReference".

Once that is complete, run the sample. For me, the error no longer happens after the migration.

See also #492

Vechkanov commented 1 year ago

Thank you! This actions helped. Am I right that packages.config is not supported by your library anymore?

ericsink commented 1 year ago

Am I right that packages.config is not supported by your library anymore

packages.config is currently not working for this library. I might fix that, but I rather doubt it, and the longer I wait, the less likely it is.