Ограничения XamarinXamarin limitations
Microsoft.Data.Sqlite предназначен для .NET Standard 2.0 и поддерживается в Xamarin.Microsoft.Data.Sqlite targets .NET Standard 2.0 and is supported on Xamarin. В следующей таблице показано, для каких платформах пакет SQLitePCLRaw по умолчанию предоставляет собственные двоичные файлы SQLite.The following table shows which platforms the default SQLitePCLRaw bundle provides native SQLite binaries for. Дополнительные сведения об использовании разных пакетов и предоставлении собственных двоичных файлов SQLite см. в разделе Пользовательские версии SQLite.See Custom SQLite versions for details on using a different bundle or providing your own native SQLite binaries.
ПлатформаPlatform | Двоичные файлы SQLiteSQLite binaries |
---|---|
Xamarin.AndroidXamarin.Android | —— |
arm64-v8a |
✔✔ |
armeabi-v7a |
✔✔ |
x86 |
✔✔ |
x86_64 |
✔✔ |
Xamarin.iOSXamarin.iOS | ✔✔ |
Xamarin.MacXamarin.Mac | ✔✔ |
Xamarin.TVOSXamarin.TVOS | ✔✔ |
UWPUWP | —— |
arm |
✔✔ |
arm64 |
✔✔ |
x64 |
✔✔ |
x86 |
✔✔ |
iOSiOS
Microsoft.Data.Sqlite пытается автоматически инициализировать пакеты SQLitePCLRaw.Microsoft.Data.Sqlite tries to automatically initialize SQLitePCLRaw bundles. Увы, из-за ограничений статической компиляции для Xamarin.iOS попытка завершается неудачей и появляется следующая ошибка.Unfortunately, because of limitations in the ahead-of-time (AOT) compilation for Xamarin.iOS, the attempt fails and you get the following error.
Необходимо вызвать
SQLitePCL.raw.SetProvider()
.You need to callSQLitePCL.raw.SetProvider()
. Если используется пакет набора, это делается путем вызоваSQLitePCL.Batteries.Init()
.If you're using a bundle package, this is done by callingSQLitePCL.Batteries.Init()
.
Чтобы инициализировать пакет, добавьте следующую строку кода в приложение перед использованием Microsoft.Data.Sqlite.To initialize the bundle, add the following line of code to your app before using Microsoft.Data.Sqlite.
SQLitePCL.Batteries_V2.Init();