問題描述
我按照 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模板網!