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

VTable setup exception since 2.05 under iOS #461

Closed db2222 closed 2 years ago

db2222 commented 2 years ago

Since version 2.05 the following exception occurs: System.TypeInitializationException: The type initializer for 'SQLite.SQLiteConnection' threw an exception. ---> System.TypeLoadException: VTable setup of type SQLitePCL.SQLite3Provider_internal failed at SQLite.SQLiteConnection..cctor () [0x00016] in <01c96d…

It works fine under Android.

I believed that this must have to do with the other reported problems regarding iOS with this version. However the issue remains after updating to version 2.07 where it seems to fixed for the others.

The only workaround I could find for now was to explicitly downgrade to 2.04 for iOS.

What could be the reason for this issue? Do I need to change something in regards to the setup since the newer versions?

Thanks in advance!

ericsink commented 2 years ago

Hmmm. I have a theory about this. I need to investigate.

db2222 commented 2 years ago

@ericsink Did you find time to analyse and maybe figured it out? Thanks :-)

ericsink commented 2 years ago

Well, not exactly. :-(

But I haven't forgotten. I mean, I looked at this again this morning. :-)

I'll get back to this as soon as I can. Thanks for your patience.

ericsink commented 2 years ago

Hmmm. Which SQLitePCLRaw packages are you using?

db2222 commented 2 years ago

We currently have the following NuGet packages related to SQLite installed:

In general they are all added in netstandard2.1 class library. This lib is referenced in the iOS project. As a workaround we have installed 2.0.4 inside the iOS project to force a downgrade.

Come to think of it akavache.sqlite3 should then be the problem as this forces the downgrade to 2.0.4 correct? Meaning there is a mixture between the versions. I just had a look at it with Rider: grafik

Thanks once again :-)

db2222 commented 2 years ago

Just FYI. I just tested what happens if I add SQLitePCLRaw.lib.e_sqlite3.ios with version 2.0.6 to the iOS project = same error.

ericsink commented 2 years ago

Ah, you have Akavache. That might be relevant here, as bundle_green and bundle_e_sqlite3 are disagreeing about how to deal with iOS. Although you said things worked with 2.0.4, so I'm still confused about that.

Anyway, try this:

<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.0.4" ExcludeAssets="All" />

which should force bundle_green to be the only one. Curious if this makes a difference.

db2222 commented 2 years ago

@ericsink I will check and report in a couple of days as I am away.

db2222 commented 2 years ago

@ericsink I have tested it. Unfortunately the same error remains.

Furthermore out of interest I tested it with explicitly adding SQLitePCLRaw.lib.e_sqlite3.ios version 2.0.6. However this also brings no change.

db2222 commented 2 years ago

@ericsink Akavache have released a new version = 7.3.47. This bumps SQLitePCLRaw.bundle_e_sqlite3 up to 2.0.7. It now works again.

Furthermore your suggested solution might have worked as I noticed something which I wasn't aware of anymore last week. There was a further reference to Avakache in another project in the iOS app hierarchy (netstandard2.1 class library -> iOS common project -> specific iOS app itself). I completely overlooked that and therefore didn't change it also in the iOS common project which most likely caused a downgrade/mixture again ;-)

Thanks once again for your help & patience :-)