Carnefix
Carnefix

Reputation: 9

SQLite.Interop.dll Issue on a Raspberry Pi

I have currently an issue with the SQLite.Interop.dll. My Application is a .net code-based rest server targeted at the netcoreapp3.1 Framework. It is being deployed via VS Powershell with the command

dotnet -c release -r linux-arm

for a raspbian os. The linux-arm is being used since it is an armv7l kernel.

The Server is running fine until I open a specific interface that uses SQLite to access the database. It then throws these exceptions:

System.EntryPointNotFoundException: Unable to find an entry point named 'SI7fca2652f71267db' in shared librar
    at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op)
    at System.Data.SQLite.SQLite3.StaticIsInitialized()
    at System.Data.SQLite.SQLiteLog.PrivateInitialize(String className)
    at System.Data.SQLite.SQLiteLog.Initialize(String className)
    at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework)
    at System.Data.SQLite.SQLiteConnection..ctor(String connectionString)
    at RestApplication.Class.Class_SAPTyreDatabase.CreateConnection() in D:\****\VisualStudio2019\RestApplicat
    at RestApplication.Class.Class_SAPTyreDatabase..ctor(String sqliteConnectionString) in D:\****\VisualStudi
    at RestApplication.Controllers.SapInterfaceController..ctor() in D:\****\VisualStudio2019\RestApplication\
    at lambda_method(Closure , IServiceProvider , Object[] )
    at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass4_0.<CreateActivator>
    at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFa
    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object&
    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
 --> End of stack trace from previous location where exception was thrown ---
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(Resou
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, 
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
 --> End of stack trace from previous location where exception was thrown ---
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker in
    at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task
    at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMidd

It then restarts the service and gives out this exception:

System.DllNotFoundException: Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies. 
    at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op)

I looked it up in other threads and it was suggested that I have to add the required DLL to the application directory since there is an issue with the deployment. The sqlite wiki also described adding the dll to an x64 / x86 folder. But I was not sure which version to download.

Upvotes: -1

Views: 721

Answers (2)

Roolingen
Roolingen

Reputation: 301

For raspberry pi running on linux-arm64 and my project based on .NET 9, when I encountered "System.DllNotFoundException: Unable to load shared library 'SQLite.Interop.dll'" for Serilog.Sinks.SQLite, here's what helped:

 - Removed Serilog.Sinks.SQLite
 - Added Serilog.Sinks.SQLite.Microsoft
 - Added SQLitePCLRaw.bundle_e_sqlite3

The Serilog.Sinks.SQLite.Microsoft package relies on Microsoft.Data.Sqlite package instead of System.Data.Sqlite package and correctly calls SQLitePCL.Batteries_V2.Init() method that is within SQLitePCLRaw.bundle_e_sqlite3 package. SQLitePCLRaw correctly includes/resolves linux-arm64 dependency.

I was also using EF Core and switched from Sqlite to Sqlite.Core:

 - Removed Microsoft.EntityFrameworkCore.Sqlite
 - Added Microsoft.EntityFrameworkCore.Sqlite.Core

The main issue is Serilog.Sinks.SQLite does not correctly support linux-arm64 builds.

Upvotes: 0

Dom5230
Dom5230

Reputation: 1

I am working on hosting a blazor application on a raspberry pi using Sqlite. I ran into the same issue.

What I did to resolve this:

  1. Installed Microsoft.Data.Sqlite (not Sqlite.Core)
  2. Changed project references to use this package.
  3. Removed System.Data.Sqlite (apparently the one causing the issue)

Upvotes: 0

Related Questions