且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Xamarin SQLite“这是‘诱饵’"

更新时间:2022-11-05 17:29:23

您是否已将 SQLite 包添加到您的所有项目中?您需要将其添加到应用项目以及 PCL 中.

Have you added the SQLite package to all your projects? You need to add it to the app projects as well as the PCLs.

这就是错误告诉你的.它使用一种称为诱饵和开关"的技巧,通过它在 PCL 中安装一个具有特定界面的虚拟程序集,并在 Android 和 iOS 应用程序中安装一个具有相同界面的平台特定程序集,该程序集实际上与数据库进行交互.这个想法是您针对 PCL 进行编码,但在运行时使用库的平台特定版本.您可以在 https://web.archive.org/web/20161209075521/http://log.paulbetts.org/the-bait-and-switch-pcl-trick/

This is what the error is telling you. It uses a trick called 'bait and switch' whereby it installs a dummy assembly in the PCL with a particular interface, and in the Android and iOS apps it installs a platform specific assembly with an identical interface that actually does the interactions with the database. The idea is you code against the PCL, but at run time the platform specific version of the library is used. You can read more about this pattern at https://web.archive.org/web/20161209075521/http://log.paulbetts.org/the-bait-and-switch-pcl-trick/

但本质上,此错误是告诉您尚未在特定于平台的项目中安装 NuGet 包.

Essentially though, this error is telling you that you haven't installed the NuGet package in your platform-specific projects.