使用 SQLite-WinRT 包装器构建问题

Build Problems with SQLite-WinRT Wrapper

添加 SQLite-WinRT 数据库包装器后,我无法让我的应用程序针对 ARM 目标构建。我可以用一个简单的测试应用重现它,如下所示:

(这是在 Visual Studio 2013 年完成的。)

  1. 创建一个空的 Windows 8.1 通用应用程序 (WinRT)
  2. 为 Windows Phone 8.1 和 下载 SQLite Windows 运行时 (Windows 8.1) 使用 Tools/Extensions 和更新 的 SQLite。将它们添加到各自项目的引用中。
  3. 使用 NuGet,将 SQLite-WinRT 包添加到每个项目。
  4. 为 x86 构建(本地机器或 phone 模拟器)-> 没问题。
  5. 为 ARM(phone 设备)构建 -> 构建错误如下所示(独立于调试或发布构建)。

There was a mismatch between the processor architecture of the project being built "ARM" and the processor architecture, "x86", of the implementation file "C:\Users\jr\Documents\Visual Studio 2015\Projects\sqlite-test\packages\Sqlite-Winrt.3.8.7.1\lib\wpa81\SQLiteWinRT.dll" for "C:\Users\jr\Documents\Visual Studio 2015\Projects\sqlite-test\packages\Sqlite-Winrt.3.8.7.1\lib\wpa81\SQLiteWinRT.winmd". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and implementation file, or choose a winmd file with an implementation file that has a processor architecture which matches the targeted processor architecture of your project.

我发布了一个小测试项目here(Windows Phone 8.1空项目,添加了SQLite,通过NuGet添加了SQLite-WinRT)。

转到项目属性打开构建选项卡并将目标平台设置为 ARM

编辑 您已添加 WinRt sqlite。它是在 x86 上构建的,当你想在 ARM 进程架构上构建它时,它无法构建你需要删除 WinRTSQlite dll,你的项目才能正常工作。这里是Code

希望对您有所帮助

我已经下载了你的项目,在参考资料中我发现你正在使用 SQLite-WinRT 和 sqlite for windows phone 8.1,你不需要两者。

一旦删除 SQLite-WinRT,您的项目就会开始编译。

编辑:

在通用应用程序中,您只需添加正确的引用,如果是 phone 项目,只需为 windows phone 8.1 添加 sqlite,而不是在 windows 8.1 应用仅添加 SQLite-WinRT

解决 NuGet 包问题的一个解决方法是将 sqlite-winrt 源添加到您的 phone 或通用应用程序。

  1. 工具 -> 扩展和 Windows Phone 8.1(以及通用 Windows 运行时 (Windows 8.1))中安装 SQLite更新 如果还没有更新
  2. 添加对各个项目的引用
  3. 下载 sqlite-winrt 包装器sources
  4. 将 SQLiteWinRTPhone81(RT)(如果需要,还有 SQLiteWinRT81)文件夹复制到您的解决方案
  5. 将项目添加到 Visual Studio 中的解决方案(右键单击解决方案 -> 添加 -> 现有项目
  6. 添加对各个项目的引用
  7. 编辑 sqlite-winrt 项目的引用以指向正确版本的 SQLite(右键单击项目 -> 属性 -> 通用属性 -> 引用 ): 在项目中添加对当前 SQLite 版本的引用并删除旧引用
  8. 构建您的解决方案