【问题标题】:SQLite exception when creating a connection创建连接时出现 SQLite 异常
【发布时间】:2015-09-10 23:21:41
【问题描述】:

我在创建连接时收到 SQLite 异常。

这在我安装 VS2015 RTM 之前有效。

客户 (PCL):

 _databaseConnection = DependencyService.Get<IDatabase>().Connect();

Android 项目:

 public SQLiteConnection Connect()
 {
    var fileName = "my_file.db3";
    var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
    var path = Path.Combine(documentsPath, fileName);
    var connection = new SQLiteConnection(path);

    return connection;
 }

执行时收到异常:

 var connection = new SQLiteConnection(path);

构建配置出现问题。这是诱饵 程序集,供可移植库引用,并且应该 永远不会成为应用程序的一部分。

注意:

SQLitePCL.raw_basic 在 0.7.1 每当我尝试将版本升级到 0.8.1 时都会出错

再一次,这一切都在我安装 VS2015 RTM 之前工作 有什么建议吗?

【问题讨论】:

  • 您使用的是哪个 SQLite-NET nuget?有一些类似名称的包,所以很高兴知道。我推荐这个:nuget.org/packages/sqlite-net-pcl 升级到 VS2015 时是否更新了其他任何内容,或者更改了正在使用的 PCL 配置文件...听起来有点像项目类型不再受 nuget 支持。

标签: sqlite xamarin.forms


【解决方案1】:

您需要初始化一个新连接,并且需要一个 ISQLitePlatform 实现。

var platform = new SQLitePlatformAndroid();
var connection = new SQLiteConnection(platform, path);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多