我按照 this 指南尝试创建 SQLite 数据库以我的项目.但是总是出现同样的错误,完全按照文章的步骤操作.
I follow this guide trying to create a SQLite database to my proyect. But always got same error, doing the exactly steps of the article.
System.Exception: This is the 'bait'. You probably need to add one of the SQLitePCLRaw.bundle_* nuget packages to your platform project.
您是否已将 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.
这篇关于Xamarin SQLite“这是‘诱饵’"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!