reactiveui / Akavache

An asynchronous, persistent key-value store created for writing desktop and mobile applications, based on SQLite3. Akavache is great for both storing important data as well as cached local data that expires.
https://evolve.xamarin.com/session/56e2044afd00c0253cae33a3
MIT License
2.43k stars 288 forks source link

SQLitePCL in NETSTANDARD error #545

Closed clarghi closed 2 years ago

clarghi commented 4 years ago

Describe the bug

Using the latest version in .NET STANDARD 2.0.3 and Android the InMemory work, but if I try to save a value using UserAccount a SQLite error is throwed:

"System.MissingMethodException: Method not found: int SQLitePCL.raw.sqlite3_bind_blob(SQLitePCL.sqlite3_stmt,int,System.ReadOnlySpan`1)"

I have initialized in App.xaml.cs using these code:

        BlobCache.ApplicationName="TEST";
        Registrations.Start("TEST");
        BlobCache.EnsureInitialized();

And then called this code on button click:

var test = await BlobCache.UserAccount.InsertObject("AAA", "http://www.AAA.it");

Seems related to SQLite PCL (installed in NETSTANDARD project), but I have not found a way or a workaround to resolve it.

Steps To Reproduce

  1. Create a blank Xamarin.Forms project
  2. Add below code
  3. Run the Android project (I use 8.1).
open-collective-bot[bot] commented 4 years ago

Hey @clarghi :wave:,

Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our Open Collective and consider contributing financially.

https://opencollective.com/reactiveui

PS.: We offer priority support for all financial contributors. Don't forget to add priority label once you start contributing :smile:

ReactiveUI - Open Collective
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms!
JMakhoul commented 3 years ago

I have the same issue, is there any solution?

ChrisPulman commented 3 years ago

Do you have the following package in the Android project <PackageReference Include="SQLitePCLRaw.lib.e_sqlite3" Version="2.0.4" />

If this doesn't solve your issue then I can take a look over the next few days. Please try to migrate to CacheDatabase many thanks

AmrAlSayed0 commented 2 years ago

I'm also hitting this issue

Exception Type : System.MissingMethodException
Message : Method not found: System.ReadOnlySpan`1<byte> SQLitePCL.raw.sqlite3_column_blob(SQLitePCL.sqlite3_stmt,int)
Source : mscorlib
Data : No Data
HelpLink : No HelpLink
HResult  : -2146233069
StackTrace : 
      at Akavache.Sqlite3.SqliteOperationQueue.MarshalCompletion[T] (System.Object completion, System.Func`1[TResult] block, System.IObservable`1[T] commitResult) [0x00012] in D:\a\Akavache\Akavache\src\Akavache.Sqlite3\Queues\OperationQueue.cs:488 
    --- End of stack trace from previous location where exception was thrown ---

      at System.Reactive.PlatformServices.ExceptionServicesImpl.Rethrow (System.Exception exception) [0x00000] in /_/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServicesImpl.cs:19 
      at System.Reactive.ExceptionHelpers.Throw (System.Exception exception) [0x00000] in /_/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.cs:16 
      at System.Reactive.Subjects.AsyncSubject`1[T].GetResult () [0x00038] in /_/Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs:430

I tried upgrading to beta and downgrading Akavache/Sqlite but it didn't help

AmrAlSayed0 commented 2 years ago

After some investigation, this is probably a build issue. Building the same sample with Visual Studio 2022 P4.1 (Xamarin.Android v12+) gets me this error. The same sample with latest stable Visual Studio 2019 16.11.3 (Xamarin.Android 11.4.0.5) works fine and doesn't have this issue.

My guess is that something broke between these 2 version that caused the SQLite dll to not be copied to the final apk.

EmmanVazz commented 2 years ago

I have the same issue. Same VS 2022 issue. Only workaround I could find is setting everything to use BlobCache.InMemory.

Geronatsios commented 2 years ago

I have the same problem only in iOS xamarin , Android works exception : Method not found: int SQLitePCL.raw.sqlite3_bind_blob(SQLitePCL.sqlite3_stmt,int,System.ReadOnlySpan`1) VS 2019 16.11.5 preview

Geronatsios commented 2 years ago

I installed VS 2019 16.9 release and it works.....

glennawatson commented 2 years ago

We been busy working a rewrite at the moment since akavache needed it. Should solve issues like this one

CrosswiredStudios commented 2 years ago

Any idea when the rewrite will be available? I'm also having this issue :(

glennawatson commented 2 years ago

It's around but it's not 100% complete. Checkout the ReactiveMarbles/CachedDatabase repo.

It doesn't have the concept of an "Akavache.UserBlob" you have to provide your own directories at the moment.

I know of about 3 large projects using it though.

CrosswiredStudios commented 2 years ago

we have a very mature product (I work for an ISP) that uses akavache extensively. Migrating to another platform would take a lot effort as it would need to get approved, added to a sprint, ect. If you think thats still the correct route for us we will have to consider it. Everything works in VS 2019 so we still have time before we get pushed to 2022.

glennawatson commented 2 years ago

In your scenario best to wait out, we will be migrating some of those changes across. I'm aiming for this week since there's been some Visual Studio 2022 issues I need to fix out.

covalliance commented 2 years ago

what is the workaround for this ? I cannot run the app on VS2022, can't really make more blocking than that...

covalliance commented 2 years ago

updating to latest version of VS 2022 fixes the issue.

messiassouza commented 2 years ago

"System.MissingMethodException: Method not found: int SQLitePCL.raw.sqlite3_bind_blob(SQLitePCL.sqlite3_stmt,int,System.ReadOnlySpan`1)"

do not Work in VS 17.2.1

glennawatson commented 2 years ago

Going to close this one for the moment, just due to it being a downstream issue with SQLitePCL.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.