问题描述
构建成功,但是当涉及到此方法时,它会抛出异常.这发生在我在 NuGet Packages 更新新包时.
The build is success but when it comes to this method, it throws exception. This happened when I updated new packages at 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;
}
这是图片.
更新:
这个包来自 .Droid
This packages from .Droid
这个包来自 Portable
This package from Portable
推荐答案
这很烦人,但很有可能您将不得不删除所有这些包并重新安装它们.尝试删除它们并添加以下包
It's annoying, but there's a very good chance you're going to have to delete all of those packages and reinstall them. Try to remove them and add the following packages
本地项目中的 SQLitePCLRaw.bundle_green 1.1.2 版(不在 PCL 中)
SQLitePCLRaw.bundle_green Version 1.1.2 in your native projects (Not in PCL)
SQLitePCLRaw.core 1.1.2 版在您的本机项目中(不在 PCL 中)
SQLitePCLRaw.core Version 1.1.2 in your native projects (Not in PCL)
SQLitePCLRaw.lib.e_sqlite3.android 1.1.2 版
SQLitePCLRaw.lib.e_sqlite3.android Version 1.1.2
SQLitePCLRaw.provider.e_sqlite3.android 1.1.2 版
SQLitePCLRaw.provider.e_sqlite3.android Version 1.1.2
SQLitePCLRaw.provider.sqlite3.ios_unified 1.1.2 版
SQLitePCLRaw.provider.sqlite3.ios_unified Version 1.1.2
然后在创建数据库时,使用以下代码作为路径对其进行初始化:
and then when you create the database, initialise it using the following code as the path:
string path = System.IO.Path.Combine(System.Environment
.GetFolderPath(System.Environment.SpecialFolder.Personal), "localstore.db");
或
如果这不起作用,请将它们全部删除,并在您的所有项目中仅添加以下一个
If that doesn't work, remove all of them and only add the following one all of your projects
https://www.nuget.org/packages/sqlite-net-pcl/
希望能帮到你
这篇关于Xamarin 表单 Sqlite 连接:找不到方法:int SQLite.SQLiteConnection.CreateTable<!0>(SQLite.CreateFlags)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!