【问题标题】:Getting error while making SQLite Connection in Xamarin PCL在 Xamarin PCL 中进行 SQLite 连接时出错
【发布时间】:2017-10-13 01:44:40
【问题描述】:

我正在关注本教程在 Xamarin 中的 SQLite 实践:

https://code.tutsplus.com/tutorials/an-introduction-to-xamarinforms-and-sqlite--cms-23020

现在我被困在这里

公共随机思想数据库() { _connection = DependencyService.Get"ISQLite"().GetConnection(); }

ISQLite是PCL中的一个接口

它给出了这个错误

错误 CS0119 'DependencyService.Get(DependencyFetchTarget)' 是一种方法,在给定的上下文 LocalStorage 中无效

【问题讨论】:

  • 您的意思是写DependencyService.Get<ISQLite>()?你也碰巧有一个ISQLite.GetConnection 属性,类似于this 问题吗?
  • DependencyService.Get().GetConnection();它有效。
  • 一束感谢 :(
  • 是的。实际上我是 Xamarin 的新手。从 Android Studio 转移到 Xamarin

标签: sqlite xamarin xamarin.forms


【解决方案1】:

改用以下内容:

public RandomThoughtDatabase () { _connection = DependencyService.Get<ISQLite>().GetConnection(); }

【讨论】:

    猜你喜欢
    • 2017-06-24
    • 2018-03-22
    • 2023-03-19
    • 1970-01-01
    • 2017-07-02
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多