問(wèn)題描述
我按照 this 指南嘗試創(chuàng)建 SQLite 數(shù)據(jù)庫(kù)以我的項(xiàng)目.但是總是出現(xiàn)同樣的錯(cuò)誤,完全按照文章的步驟操作.
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 包添加到您的所有項(xiàng)目中?您需要將其添加到應(yīng)用項(xiàng)目以及 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.
這就是錯(cuò)誤告訴你的.它使用一種稱為誘餌和開(kāi)關(guān)"的技巧,通過(guò)它在 PCL 中安裝一個(gè)具有特定界面的虛擬程序集,并在 Android 和 iOS 應(yīng)用程序中安裝一個(gè)具有相同界面的平臺(tái)特定程序集,該程序集實(shí)際上與數(shù)據(jù)庫(kù)進(jìn)行交互.這個(gè)想法是您針對(duì) PCL 進(jìn)行編碼,但在運(yùn)行時(shí)使用庫(kù)的平臺(tái)特定版本.您可以在 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/
但本質(zhì)上,此錯(cuò)誤是告訴您尚未在特定于平臺(tái)的項(xiàng)目中安裝 NuGet 包.
Essentially though, this error is telling you that you haven't installed the NuGet package in your platform-specific projects.
這篇關(guān)于Xamarin SQLite“這是‘誘餌’"的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!