【问题标题】:Unable to load DLL 'sqlite3' - for Windows Universal Mobile无法加载 DLL 'sqlite3' - 适用于 Windows Universal Mobile
【发布时间】:2016-04-01 07:47:55
【问题描述】:

我使用带有 SP2 的 Visual Studio 2015。我尝试使用 sqlite 创建 Windows 通用应用程序。我为 Unversal Windows Platforms 和 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()

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

【问题讨论】:

  • 您是否尝试为新的 sqlite 版本更新您的 nuget 包?
  • 我使用 SQLite.Net-PCL 3.1.1 和 SQLite.Net.Async-PCL 3.1.1。这是最后一个版本。
  • 对于 SQLite.Net.Async-PCL,我正在使用 3.0.5,因为 3.1.1 在我的项目中弹出了一些错误,除了我的项目在所有三个桌面、移动设备和模拟器上都可以正常工作。它是仅在当前项目中发生还是在所有其他项目中发生?
  • 第一个工作项目中的这个问题。我创建了清晰的 Windows 通用项目 - 但我有这个问题
  • 由于问题可能出在您当前的工作环境中,或者您已经参考了一些参考资料,您能否分享一个具有相同错误的示例应用程序。

标签: sqlite visual-studio-2015 windows-phone win-universal-app sqlite-net


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    1. 用于通用 Windows 平台的 Sqlite
    2. Visual C++ Runtime 2015 for Unversal Windows Platfrom

    它仍然有效!

    【讨论】:

    • 这应该是预期的答案。如果您看不到“用于通用 Windows 平台的 Sqlite”选项.. 然后从 Sqlite.org 安装 VSIX
    【解决方案3】:

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

    【讨论】:

    • 很抱歉,这对我不起作用 :(。“通用应用程序平台的 SQLite”是旧名称“通用 Windows 平台的 SQLite”?
    • 哦,是的,你是对的,从这个tutorial 你可以看到前面是SQLite for Universal App Platform(即使我已经安装了这个),他们已经更改为SQLite for Universal Windows Platform,但它不能工作移动模拟器意味着它来自 SQLite 端的错误。现在这就是为什么 WinRT sqlite 工作而 UWP 没有工作的原因。
    猜你喜欢
    • 2020-10-13
    • 2018-09-06
    • 1970-01-01
    • 2017-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    • 1970-01-01
    相关资源
    最近更新 更多