无法加载 DLL 'sqlite3' - 对于 Windows Universal Mobile

Unable to load DLL 'sqlite3' - for Windows Universal Mobile

我用的是 Visual Studio 2015 SP2。我尝试使用 sqlite 创建 Windows 通用应用程序。我为通用 Windows 平台和 SQLite.Net-PCl 添加了 SQLite。这是我的简单代码

var conn = new SQLiteConnection(
            new SQLitePlatformWinRT(),
            Path.Combine(ApplicationData.Current.LocalFolder.Path,  "Storage.sqlite"));

它适用于桌面。但它不适用于移动设备(在设备和模拟器中)。我得到这个异常 System.DllNotFoundException:

  HResult=-2146233052
  Message=Unable to load DLL 'sqlite3': The specified module could not be  found. (Exception from HRESULT: 0x8007007E)
Source=SQLite.Net.Platform.WinRT
TypeName=""
StackTrace:
   at SQLite.Net.Platform.WinRT.SQLite3.SetDirectory(UInt32 directoryType, String directoryPath)
   at SQLite.Net.Platform.WinRT.SQLiteApiWinRT..ctor()
   at SQLite.Net.Platform.WinRT.SQLitePlatformWinRT..ctor()
   at AppDbTest.MainPage.DbConnection()
   at AppDbTest.MainPage..ctor()
   at AppDbTest.AppDbTest_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage()
   at AppDbTest.AppDbTest_XamlTypeInfo.XamlUserType.ActivateInstance()

我试试这个 。我为 Unversal Windows 平台扩展和 SQLite.Net-PCl 重新安装了 SQLite。我创建了清晰的项目。但这对我不起作用。

已在聊天中解决。
OP 使用 Nuget 控制台解决了它: 安装包 SQLite.WinRT.UAP 并使用 "add link" ->"Extensions"->SQLite 用于 Windows 运行时
建议
很酷,但建议您使用 Extension SQLite for Universal App Platform,因为它包含大多数设备系列并且不需要 SQLite.WinRT.UAP。 在当前的 repo 中,我删除了对 Winrt 的引用,并使用这些扩展正常工作。只需检查您系统上安装的 Sqlite vsix 包是否正确。

我添加了对通用 Windows 平台应用程序的 Visual C++ 2015 运行时的引用。这是为我工作。我将 SQLite 用于通用 Windows 平台。

确保您当前添加了 2 个引用

  1. 通用的 Sqlite Windows 平台
  2. 通用 Windows 平台的 Visual C++ 运行时 2015

仍然有效!