praeclarum / sqlite-net

Simple, powerful, cross-platform SQLite client and ORM for .NET
MIT License
4.01k stars 1.42k forks source link

SQLite-net-sqlcipher not compatible with Microsoft App Center #852

Open CaseAlexander opened 5 years ago

CaseAlexander commented 5 years ago

I'm using sqlite-net-sqlcipher 1.6.258-beta. After installing Microsoft.AppCenter nuget, I get an exception in the SQLiteConnectionString constructor (works fine without AppCenter).

Method not found: 'Void SQLite.SQLiteConnectionString..ctor(System.String, Boolean, System.Object, System.Action`1<SQLite.SQLiteConnection>, System.Action`1<SQLite.SQLiteConnection>, System.String)'.
ericsink commented 5 years ago

The problem is that App Center takes its dependency on bundle_green (IIRC) and having two bundles is problematic.

The workaround is to get rid of bundle_green:

<PackageReference Include="SQLitePCLRaw.bundle_green">
      <Version>TODO</Version>
      <ExcludeAssets>All</ExcludeAssets>
</PackageReference>
CaseAlexander commented 5 years ago

Thank you, I'm looking into this.
I reference sqlite-net-sqlcipher in a database assembly and Microsoft App Center in the UWP application and the forms assembly. I actually have 21 assemblies in this project, so it's rather large. Should I add the bundle_green exclusion to the csproj of the assembly using sql-cipher or the uwp assembly using app center? They're not one and the same. I guess I have to also figure out what version of bundle_green MS is using.

I really appreciate this hint, gives me some direction!

CaseAlexander commented 5 years ago

Since you gave me that workaround, I was able to do some targeted research ... and I can now see this is a wide-spread issue.

In short, here's my project structure:

MyApp.Forms (Xamarin.Forms netstandard project)

Adding the exclusion you gave (as well as those found on the other related thread) in any of the projects (tried various combinations), I was able to get the app to run, but MS App Center fails because the sql-lite-net version wasn't what was expected (I don't recall the exact exception).

I'll keep working at it and report if I figure it out. Thank you again for the support!

ericsink commented 5 years ago

Here's another thing to consider:

In MyApp.Database, add the reference to sqlite-net-base instead of sqlite-net-sqcipher.

Then, in MyApp.Forms.UWP, add a reference to SQLitePCLRaw.bundle_sqlcipher. And in your app startup code, call SQLitePCL.Batteries_V2.Init();

The idea here is that the bundle only needs to be added to the head project, not to a library. sqlite-net-sqlcipher brings in bundle_sqlcipher. sqlite-net-base only brings in SQLitePCLRaw.core, which is all it really needs.

I'm not saying this will fix any specific problem I see. This is just another tip that may or may not help as you dig through this.

CaseAlexander commented 5 years ago

That's an excellent idea, and I was just thinking I should try to add the individual references rather than the sqlite-net-sqlcipher bundle. I was hoping it'd give me greater control over what to exclude.

It'll be a few days before I can around to it, but if I sort it out I'll certainly post. Thanks again

Brosten commented 4 years ago

Any news around this problem? I've read a lot of how to fix this, but it's all for older versions of AppCenter. My setup is like this:

Net std lib: sqlite-net-base 1.6

uwp/Android/ios SQLitePCLRaw.bundle_sqlcipher 1.1.14

I also use Microsoft.Appcenter v 2.6.4 This setup works good!

But as soon as I update Appcenter to 3.x, I get missing method exceptions from sqlite. Any idéas?

@ericsink