Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin表单Sqlite连接:未找到方法:int-Sqlite.SQLiteConnection.CreateTable<;!0>;(SQLite.CreateFlags)_Sqlite_Xamarin_Xamarin.forms - Fatal编程技术网

Xamarin表单Sqlite连接:未找到方法:int-Sqlite.SQLiteConnection.CreateTable<;!0>;(SQLite.CreateFlags)

Xamarin表单Sqlite连接:未找到方法:int-Sqlite.SQLiteConnection.CreateTable<;!0>;(SQLite.CreateFlags),sqlite,xamarin,xamarin.forms,Sqlite,Xamarin,Xamarin.forms,构建是成功的,但是当涉及到这个方法时,它抛出异常。这发生在我在NuGet packages更新新包时 public static string checkToken() { string token1 = ""; try { SQLiteConnection db = DependencyService.Get<SQLiteInterface>().GetConne

构建是成功的,但是当涉及到这个方法时,它抛出异常。这发生在我在NuGet packages更新新包时

public static string checkToken()
        {
            string token1 = "";
            try
            {
                SQLiteConnection db = DependencyService.Get<SQLiteInterface>().GetConnection();
                db.CreateTable<Token>();
            Token t = db.Table<Token>().FirstOrDefault();
            if (t != null)
            {
                DateTime dt = t.timeCreated;
                DateTime tmp = DateTime.Now;

                double diff = (tmp - dt).TotalMinutes;
                if (diff > 60.0 || App.IsUserLoggedIn == false)
                {
                    token1 = "expired";
                    db.Delete(t);
                }
                else
                {
                    token1 = t.token;
                }
            }
        }
        catch (Exception e)
        {
            e.ToString();
        }
        return token1;
    }
publicstaticstringchecktoken()
{
字符串标记1=“”;
尝试
{
SQLiteConnection db=DependencyService.Get().GetConnection();
db.CreateTable();
令牌t=db.Table().FirstOrDefault();
如果(t!=null)
{
DateTime dt=t.timeCreated;
DateTime tmp=DateTime.Now;
双差=(tmp-dt)。总分钟数;
如果(差异>60.0 | | App.IsUserLoggedIn==false)
{
token1=“过期”;
db.删除(t);
}
其他的
{
token1=t.token;
}
}
}
捕获(例外e)
{
e、 ToString();
}
返回令牌1;
}
这是图片

更新:

此文件包来自.Droid

此软件包来自便携式

这很烦人,但很有可能您必须删除所有这些软件包并重新安装它们。尝试删除它们并添加以下包

SQLitePCLRaw.bundle_本机项目中的绿色版本1.1.2(不在PCL中)

本机项目中的SQLitePCLRaw.core版本1.1.2(不在PCL中)

SQLitePCLRaw.lib.e_sqlite3.android版本1.1.2

SQLitePCLRaw.provider.e_sqlite3.android版本1.1.2

SQLitePCLRaw.provider.sqlite3.ios_统一版本1.1.2

然后在创建数据库时,使用以下代码作为路径对其进行初始化:

string path = System.IO.Path.Combine(System.Environment
            .GetFolderPath(System.Environment.SpecialFolder.Personal), "localstore.db");

如果这不起作用,请删除所有项目,只添加以下一个项目


我希望这会有所帮助,这很烦人,但很有可能您必须删除所有这些软件包并重新安装它们。尝试删除它们并添加以下包

SQLitePCLRaw.bundle_本机项目中的绿色版本1.1.2(不在PCL中)

本机项目中的SQLitePCLRaw.core版本1.1.2(不在PCL中)

SQLitePCLRaw.lib.e_sqlite3.android版本1.1.2

SQLitePCLRaw.provider.e_sqlite3.android版本1.1.2

SQLitePCLRaw.provider.sqlite3.ios_统一版本1.1.2

然后在创建数据库时,使用以下代码作为路径对其进行初始化:

string path = System.IO.Path.Combine(System.Environment
            .GetFolderPath(System.Environment.SpecialFolder.Personal), "localstore.db");

如果这不起作用,请删除所有项目,只添加以下一个项目


我希望这对您有所帮助,因为Janwilx72说您需要安装Nuget针对pcl和平台的sqlite net pcl软件包。不需要你提供的包裹

然后可以使用SQLiteConnection.CreateTable()并且没有问题

我在github为Android做了一个示例,您可以看看:

如果您想在ios或其他平台上执行此操作,可以查看本文:


正如Janwilx72所说,您需要安装Nuget针对pcl和平台的sqlite net pcl软件包。不需要你提供的包裹

然后可以使用SQLiteConnection.CreateTable()并且没有问题

我在github为Android做了一个示例,您可以看看:

如果您想在ios或其他平台上执行此操作,可以查看本文:


能否添加您正在使用的SQLite nuget软件包的列表?@Janwilx72 from.Droid或Portable?取决于您在哪里使用它。一些较旧的SQLite包会出现很多错误。我基本上删除了所有项目中引用sqlite的所有包,然后在共享项目中使用sqlite net pcl。这意味着您也不必通过接口来创建SQLite数据库。它在共享环境中工作project@Janwilx72我已经更新了这个问题。您正在运行哪个版本的xamarin表单?能否添加您正在使用的SQLite nuget软件包的列表?@Janwilx72 from.Droid或Portable?取决于您在哪里使用它。一些较旧的SQLite包会出现很多错误。我基本上删除了所有项目中引用sqlite的所有包,然后在共享项目中使用sqlite net pcl。这意味着您也不必通过接口来创建SQLite数据库。它在共享环境中工作project@Janwilx72我已经更新了问题。你正在运行什么版本的xamarin表单?@Ticherhaz,如果我的答复对你有帮助,请记住将我的答复标记为答复,谢谢。@Ticherhaz,如果我的答复对你有帮助,请记住将我的答复标记为答复,谢谢。