ARM64 UWP DesktopExtension – "e_sqlite3.dll is not a valid Win32 application" despite including runtimes\win-arm64\native

WorldOfBasti 136 Reputation points
2025-02-11T22:59:23.9333333+00:00

I have an UWP app with Desktop Extension (implemented like this tutorial: https://github.com/StefanWickDev/UWP-FullTrust/tree/master).

Here is my sample project, which shows this issue:

https://github.com/WorldOfBasti/issue-uwp-desktop-bridge-with-sqlite

The Desktop Extension must target .NET Framework 4.7.2 (otherwise the package cannot be built, right?). I've added the sqlite-net-pcl package (v1.9.172) to store data in a sqlite database (same issue with Microsoft.Data.Sqlite package; I switched from packages.config to PackageReference as well).

The application runs fine on x86, x64 builds. However, I received a message from a user who had issues on a new Surface 11 Pro with ARM processor. I tried to build the app for ARM64 on my machine and ran into the exception stating that "Library e_sqlite3 could not be found.":

System.TypeInitializationException: The type initializer for 'SQLite.SQLiteConnection' threw an exception. ---> System.Exception: Library e_sqlite3 not found
plat: win
suffix: DLL
possibilities (2):
    1) C:\Users\basti\Desktop\Programmieren\Sample\Sample.Package\bin\ARM64\Debug\AppX\Sample.DesktopExtension\runtimes\win-arm64\native\e_sqlite3.dll
    2) C:\Users\basti\Desktop\Programmieren\Sample\Sample.Package\bin\ARM64\Debug\AppX\Sample.DesktopExtension\e_sqlite3.dll
win TryLoad: C:\Users\basti\Desktop\Programmieren\Sample\Sample.Package\bin\ARM64\Debug\AppX\Sample.DesktopExtension\runtimes\win-arm64\native\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found
   at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
win TryLoad: C:\Users\basti\Desktop\Programmieren\Sample\Sample.Package\bin\ARM64\Debug\AppX\Sample.DesktopExtension\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found
   at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
NOT FOUND
   at SQLitePCL.NativeLibrary.Load(String libraryName, Assembly assy, Int32 flags)
   at SQLitePCL.Batteries_V2.MakeDynamic(String name, Int32 flags)
   at SQLitePCL.Batteries_V2.DoDynamic_cdecl(String name, Int32 flags)
   at SQLitePCL.Batteries_V2.Init()
   at SQLite.SQLiteConnection..cctor()
   --- End of inner exception stack trace ---
   at SQLite.SQLiteConnection..ctor(String databasePath, Boolean storeDateTimeAsTicks)
   at Sample.DesktopExtension.Program.Main(String[] args)

I tried to fix this issue by copying the missing dll into the directory using this (I added it to the .csproj of the DesktopExtension):

 <ItemGroup>
    <Content Include="C:\Users\basti\.nuget\packages\sqlitepclraw.lib.e_sqlite3\2.1.2\runtimes\win-arm64\native\e_sqlite3.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      <Link>runtimes\win-arm64\native\e_sqlite3.dll</Link>
    </Content>
  </ItemGroup> 

But then I got the following exception:

System.TypeInitializationException: The type initializer for 'SQLite.SQLiteConnection' threw an exception. ---> System.Exception: Library e_sqlite3 not found

plat: win

suffix: DLL

possibilities (2):

    1) C:\Users\basti\Desktop\Programmieren\Sample\Sample.Package\bin\ARM64\Debug\AppX\Sample.DesktopExtension\runtimes\win-arm64\native\e_sqlite3.dll

    2) C:\Users\basti\Desktop\Programmieren\Sample\Sample.Package\bin\ARM64\Debug\AppX\Sample.DesktopExtension\e_sqlite3.dll

win TryLoad: C:\Users\basti\Desktop\Programmieren\Sample\Sample.Package\bin\ARM64\Debug\AppX\Sample.DesktopExtension\runtimes\win-arm64\native\e_sqlite3.dll

thrown: System.ComponentModel.Win32Exception (0x80004005): %1 is not a valid Win32 application

   at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)

win TryLoad: C:\Users\basti\Desktop\Programmieren\Sample\Sample.Package\bin\ARM64\Debug\AppX\Sample.DesktopExtension\e_sqlite3.dll

thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found

   at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)

NOT FOUND

   at SQLitePCL.NativeLibrary.Load(String libraryName, Assembly assy, Int32 flags)

   at SQLitePCL.Batteries_V2.MakeDynamic(String name, Int32 flags)

   at SQLitePCL.Batteries_V2.DoDynamic_cdecl(String name, Int32 flags)

   at SQLitePCL.Batteries_V2.Init()

   at SQLite.SQLiteConnection..cctor()

   --- End of inner exception stack trace ---

   at SQLite.SQLiteConnection..ctor(String databasePath, Boolean storeDateTimeAsTicks)

   at Sample.DesktopExtension.Program.Main(String[] args)

So it says 'is not a valid Win32 application' and I thought it is the wrong binary file, but I've tried all the other binaries (SQLitePCLRaw.bundle_green, SQLitePCLRaw.provider.e_sqlite3, ...) that belong to this sqlite package and I always get this error. If I create a single console application with .NET Framework 4.7.2, that approach works. However in my real project using it as DesktopExtension with Package, I get that error.

I can't explain this.. Is there any configuration I didn't notice? Any guidance on how to correctly include the proper ARM64 native SQLite DLL for UWP/DesktopBridge apps would be greatly appreciated.

Many thanks in advance.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,109 questions
Universal Windows Platform (UWP)
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.