我正在尝试使用带有xamarin表单(和prism)的Sqlite,遵循此example。在Android和Portable项目中,我从nuget安装了sqlite-net-pcl。 创建表时,会出现异常(我只输出最相关的消息):
The type initializer for 'SQLite.SQLiteConnection' threw an exception.
at SQLitePCL.Batteries_V2.Init ()
System.Exception: This is the 'bait'. You probably need to add one of the SQLitePCLRaw.bundle_* nuget packages to your platform project.
...但是看看Android项目中的软件包,似乎我已经安装了“raw”软件包(它们是sqlite-net-pcl的依赖项),这里是Android项目的完整packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="1.3" targetFramework="monoandroid70" />
<package id="Microsoft.NETCore.Platforms" version="1.0.1" targetFramework="monoandroid70" />
<package id="Microsoft.Win32.Primitives" version="4.0.1" targetFramework="monoandroid70" />
<package id="NETStandard.Library" version="1.6.0" targetFramework="monoandroid70" />
<package id="Prism.Core" version="6.2.0" targetFramework="monoandroid70" />
<package id="Prism.Forms" version="6.2.0" targetFramework="monoandroid70" />
<package id="Prism.Unity.Forms" version="6.2.0" targetFramework="monoandroid70" />
<package id="sqlite-net-pcl" version="1.3.1" targetFramework="monoandroid70" />
<package id="SQLitePCLRaw.bundle_green" version="1.1.2" targetFramework="monoandroid70" />
<package id="SQLitePCLRaw.core" version="1.1.2" targetFramework="monoandroid70" />
<package id="SQLitePCLRaw.lib.e_sqlite3.android" version="1.1.2" targetFramework="monoandroid70" />
<package id="SQLitePCLRaw.provider.e_sqlite3.android" version="1.1.2" targetFramework="monoandroid70" />
<package id="System.AppContext" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Collections" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Collections.Concurrent" version="4.0.12" targetFramework="monoandroid70" />
<package id="System.Console" version="4.0.0" targetFramework="monoandroid70" />
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Diagnostics.Tools" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Diagnostics.Tracing" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Globalization" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Globalization.Calendars" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.IO" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.IO.Compression" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.IO.Compression.ZipFile" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.IO.FileSystem" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.IO.FileSystem.Primitives" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Linq" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Linq.Expressions" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Net.Http" version="4.3.0" targetFramework="monoandroid70" />
<package id="System.Net.Http.Formatting.Extension" version="5.2.3.0" targetFramework="monoandroid70" />
<package id="System.Net.Primitives" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Net.Sockets" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.ObjectModel" version="4.0.12" targetFramework="monoandroid70" />
<package id="System.Reflection" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Reflection.Extensions" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Reflection.Primitives" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Runtime" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Runtime.Handles" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Runtime.InteropServices" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" targetFramework="monoandroid70" />
<package id="System.Runtime.Numerics" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Security.Cryptography.Algorithms" version="4.2.0" targetFramework="monoandroid70" />
<package id="System.Security.Cryptography.Encoding" version="4.0.0" targetFramework="monoandroid70" />
<package id="System.Security.Cryptography.Primitives" version="4.0.0" targetFramework="monoandroid70" />
<package id="System.Security.Cryptography.X509Certificates" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Text.Encoding" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Text.Encoding.Extensions" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Text.RegularExpressions" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Threading" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Threading.Tasks" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Threading.Timer" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Xml.ReaderWriter" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Xml.XDocument" version="4.0.11" targetFramework="monoandroid70" />
<package id="Unity" version="4.0.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="monoandroid70" />
<package id="Xamarin.Forms" version="2.3.1.114" targetFramework="monoandroid70" />
</packages>
这是Portable项目的packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="1.3" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Microsoft.AspNet.SignalR.Client" version="2.2.1" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Prism.Core" version="6.2.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Prism.Forms" version="6.2.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Prism.Unity.Forms" version="6.2.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="sqlite-net-pcl" version="1.3.1" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="SQLitePCLRaw.bundle_green" version="1.1.2" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="SQLitePCLRaw.core" version="1.1.2" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Unity" version="4.0.1" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Xamarin.Forms" version="2.3.1.114" targetFramework="portable45-net45+win8+wp8+wpa81" />
</packages>
我错过了什么?