2

I am trying to deploy a lightweight ASP application on Raspberry Pi 3 Model B (running 64-bit Raspbian Lite, .NET RID is linux-arm64) with Apache2. I am developing on Linux Mint with ASP.Net Core 7 and compiling to linux-arm64 for my Raspberry Pi. My application relies on SQLite3. I tried compiling every way, but no matter what I do, when I run it on my Raspberry Pi I get:

# Unhandled exception. System.DllNotFoundException: Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/var/www/html/leafletasp/SQLite.Interop.dll.so: cannot open shared object file: No such file or directory
/var/www/html/leafletasp/libSQLite.Interop.dll.so: cannot open shared object file: No such file or directory
/var/www/html/leafletasp/SQLite.Interop.dll: cannot open shared object file: No such file or directory
/var/www/html/leafletasp/libSQLite.Interop.dll: cannot open shared object file: No such file or directory

Many of the packages included don't appear to have matching DLLs or SOs. I don't know what should and shouldn't be there, but notable absences are:

  • System.Data.SQLite.Core
  • Stub.System.SQLite.Core.NetStandard (although netstandard.dll is present)
  • Everything regarding SQLite.Interop

Almost all of these yield the same error log when I attempt to run them:

  • Compile as self-contained and run with or without the ASP.NET runtime.
  • Compile as a self-contained single file.
  • Compile completely default non-self-contained and run with ASP.NET runtime.
  • Install the following NuGet packages and put them in dependencies:
    • System.Data.SQLite
    • Stub.System.Data.SQLite.Core.NetStandard
    • System.Data.SQLite.Core
    • System.Data.SQLite.EF6
  • Add the <ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles> tag to my .csproj.
  • Add the PrivateAssets="none" tag to all package references that involve SQLite (as per direction of another answer).
  • Add <PackageReference Include="SQLite.Interop" Version="1.0.0"/>. This throws compiler warnings that the package is not compatible with SDK 7 and must be inferred from Framework 4.8. Adding this does include SQLite.Interop.dll in the compiled binaries but throws an error when run, stating it has invalid ELF header.
  • Install latest apt package for sqlite3 and libsqlite3-dev.

.csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
        <RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
        <SelfContained>true</SelfContained>

<!--        does not appear to affect anything at all-->
        <ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
        <CopySQLiteInteropFiles>false</CopySQLiteInteropFiles>
        <CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles>
        <CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="HtmlAgilityPack" Version="1.11.49" />
      <PackageReference Include="Markdig" Version="0.31.0" />
      <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
      <PackageReference Include="SQLite.Interop.dll" Version="1.0.103" PrivateAssets="none"/>
      <PackageReference Include="Stub.System.Data.SQLite.Core.NetStandard" Version="1.0.118" PrivateAssets="none"/>
      <PackageReference Include="System.Data.SQLite" Version="1.0.118" PrivateAssets="none"/>
      <PackageReference Include="System.Data.SQLite.Core" Version="1.0.118" PrivateAssets="none"/>
      <PackageReference Include="System.Data.SQLite.EF6" Version="1.0.118" PrivateAssets="none"/>


    </ItemGroup>

    <ItemGroup>
      <Folder Include="Views\" />>
    </ItemGroup>

</Project>

I know getting ASP to run using Apache is a whole other hurdle, I just want to get the program to show any sign of life on Raspberry Pi.

Dai
  • 141,631
  • 28
  • 261
  • 374
  • Maybe you can find some useful information from this discussion: https://stackoverflow.com/questions/71799985/unable-to-load-dll-sqlite-interop-dll-or-one-of-its-dependencies-running-an – jason.kaisersmith Jul 17 '23 at 07:41
  • 1
    `` <-- [This is a dodgy-looking unofficial project that hasn't been updated since 2017](https://www.nuget.org/packages/SQLite.Interop.dll/) and I honestly have no idea why it it exists as it's just going to confuse people (besides, Linux uses `.so` files, not `.dll`). – Dai Jul 17 '23 at 08:28
  • Why are you referencing `System.Data.SQLite.EF6` when you aren't using EF6? – Dai Jul 17 '23 at 08:29
  • _"Add the `PrivateAssets="none"` tag to all package references that involve SQLite (as per direction of another answer)."_ - no, that's not what `privateAssets` is for. Remove that. – Dai Jul 17 '23 at 08:30
  • `Interop` libraries are "bridging" libraries that let you use old skool COM objects from .Net. This is completely unecessary to use SQLite, not to mention that you would have to put a bunch of really old COM objects on there for it to use. COM well and truly predates cross platform. In short you need to remove the reference to `SQLite.Interop.dll` and change any code that is using it. – Nick.Mc Jul 17 '23 at 08:43

0 Answers0