ericsink / SQLitePCL.raw

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

Sqlcipher doesn't work on linux-arm #314

Closed oleg-varlamov closed 4 years ago

oleg-varlamov commented 4 years ago

Using SQLitePCLRaw.bundle_green 1.1.14 Our application successfully works on linux-x86 and linux-x64. But when we try to run on ARM we get exception on startup:

Application startup exception: System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DllNotFoundException: Unable to load shared library 'sqlcipher' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libsqlcipher: cannot open shared object file: No such file or directory at SQLitePCL.SQLite3Provider_sqlcipher.NativeMethods.sqlite3_libversion_number() at SQLitePCL.SQLite3Provider_sqlcipher.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number() at SQLitePCL.raw.SetProvider(ISQLite3Provider imp) at SQLitePCL.Batteries_V2.Init() --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize() at Microsoft.Data.Sqlite.SqliteConnection..cctor() --- End of inner exception stack trace --- at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString) at WebCash.LocalServer.DAL.MainDbContext.OnConfiguring(DbContextOptionsBuilder builder) in C:\gitlab\webkassa\WebCash.LocalServer.DAL\MainDbContext.cs:line 37 at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider() at Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure.get_Instance() at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure.get_Instance() at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.GetRelationalService[TService](IInfrastructure`1 databaseFacade) at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade) at WebCash.LocalServer.Infrastructure.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in C:\gitlab\webkassa\WebCash.LocalServer\Infrastructure\Startup.cs:line 134 --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app) at Microsoft.AspNetCore.Mvc.Internal.MiddlewareFilterBuilderStartupFilter.<>cDisplayClass0_0.gMiddlewareFilterBuilder|0(IApplicationBuilder builder) at Microsoft.AspNetCore.HostFilteringStartupFilter.<>cDisplayClass0_0.b0(IApplicationBuilder app) at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.b__0(IApplicationBuilder builder) at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

I think it's because libsqlcipher.so runtime library is not present in linux-arm folder.

ericsink commented 4 years ago

You start by saying you are using SQLitePCLRaw.bundle_green, but that is not the bundle for sqlcipher. Perhaps you could post exactly which packages are involved.

oleg-varlamov commented 4 years ago

Looks like I was mistaken when specifying the package name - the package is SQLitePCLRaw.bundle_sqlcipher

ericsink commented 4 years ago

You're correct, the sqlcipher package apparently did not have support for linux-arm back in the 1.x versions.

The current version of SQLitePCLRaw is 2.0.2, and it does have linux-arm for SQLCipher. Note that the name (and package ID) of those unofficial SQLCipher builds has changed from "sqlcipher" to "e_sqlcipher", to more clearly indicate that they are not official builds.

The 2.0.2 release has a number of changes to consider before upgrading:

https://github.com/ericsink/SQLitePCL.raw/blob/master/v2.md