【发布时间】:2020-04-30 22:19:03
【问题描述】:
我有一个在 Android 上运行良好的 Xamarin Forms 应用程序,但是当我在 iOS 上运行时,我在设置数据库时收到此错误
Method not found: string SQLitePCL.raw.sqlite3_column_name(SQLitePCL.sqlite3_stmt,int)
然后当我尝试插入数据库表时
Method not found: string SQLitePCL.raw.sqlite3_errmsg(SQLitePCL.sqlite3)
该应用程序使用 mvvmlight,我在那里安装了 sqlite-net-pcl 包,也在平台代码中。所有版本都结合在一起。
我的 sqlite 的 iOS 初始化代码如下所示(在平台上)
public class SQLiteConnectionFactory : ISqliteConnectionFactory
{
readonly string Filename = "mydb";
public SQLiteConnection GetConnection()
{
var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
path = Path.Combine(path, Filename);
SimpleIoc.Default.Register<ISqliteConnectionFactory, SQLiteConnectionFactory>();
return new SQLiteConnection(path, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.SharedCache);
}
以及像这样的插入代码(在 mvvmlight 项目中)
public void SaveListData<T>(List<T> toStore)
{
try
{
lock (dbLock)
{
connection.InsertAll(toStore);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
我在使用 Xam.Android 和 sqlite-net-pcl 时遇到过问题,但在 iOS 上从来没有
我安装了 sqlite-net-pcl 1.7.302-beta 和 SQLitePCL.* 2.0.2 软件包(使用 beta 版本来防止稳定版本上的一些链接问题)
下面是安装的 iOS 包的截图
【问题讨论】:
-
这看起来像是一个 Android 解决方案,而不是 iOS。我已经完成了软件包的卸载-重新安装,什么也没有
-
确保您在 Share 项目和 iOS 项目中都将 XF 的版本更新到最新版本。