Windows 10 移动设备上的 SQLite 无法正常工作
SQLite on Windows 10 mobile not working
我想为我的应用程序创建此 SQLite 数据库,但每次尝试时都会出现此错误。
类型 'System.DllNotFoundException' 的异常发生在 SQLite.Net.Platform.WinRT.dll 但未在用户代码中处理
我安装了用于 uwp 的 SQLite,并在参考中添加了用于通用应用程序 (windows) 平台的 SQLite。
它不会发生在 Windows 桌面设备上,只是移动设备的问题。
private string _dbPath = string.Empty;
public string DbPath
{
get
{
if (string.IsNullOrEmpty(_dbPath))
{
_dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Storage.sqlite");
}
return _dbPath;
}
}
public SQLiteConnection DbConnection => new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), DbPath);
I have SQLite for uwp installed and I added SQLite for universal app (windows) platform added to the references.
It doesn;t happen on Windows Desktop, just an issue with mobile.
根据您在上面提供的代码,您使用的是 SQLite.Net-PCL NuGet Package for SQLite。
当我使用 SQLite.Net-PCL NuGet Package for SQLite 并且 only add "SQLite for Universal Windows Platform" 到参考时,我已经重现了这个问题。该代码在本地机器上运行良好,但在移动模拟器和我的 Windows Phone 上失败。
根据我的研究,SDK“SQLite for Universal Windows Platform”依赖于 SDK“Visual C++ 2015 Runtime for Universal Windows 平台应用程序 ”。
因此我们可能需要在使用 [=36= 时将 both "SQLite for Universal Windows Platform and "Visual C++ 2015 Runtime for Universal Windows Platform Apps" 添加到参考中]-PCL SQLite 的 NuGet 包。
如果只添加“SQLite for Universal Windows Platform”,我们会得到如下警告:
The SDK "SQLite.UWP.2015, Version=3.13.0" depends on the following SDK(s) "Microsoft.VCLibs, version=14.0", which have not been added to the project or were not found. Please ensure that you add these dependencies to your project or you may experience runtime issues. You can add dependencies to your project through the Reference Manager.
添加两个引用后,警告消失,问题得到解决。
我想为我的应用程序创建此 SQLite 数据库,但每次尝试时都会出现此错误。
类型 'System.DllNotFoundException' 的异常发生在 SQLite.Net.Platform.WinRT.dll 但未在用户代码中处理
我安装了用于 uwp 的 SQLite,并在参考中添加了用于通用应用程序 (windows) 平台的 SQLite。
它不会发生在 Windows 桌面设备上,只是移动设备的问题。
private string _dbPath = string.Empty;
public string DbPath
{
get
{
if (string.IsNullOrEmpty(_dbPath))
{
_dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Storage.sqlite");
}
return _dbPath;
}
}
public SQLiteConnection DbConnection => new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), DbPath);
I have SQLite for uwp installed and I added SQLite for universal app (windows) platform added to the references. It doesn;t happen on Windows Desktop, just an issue with mobile.
根据您在上面提供的代码,您使用的是 SQLite.Net-PCL NuGet Package for SQLite。
当我使用 SQLite.Net-PCL NuGet Package for SQLite 并且 only add "SQLite for Universal Windows Platform" 到参考时,我已经重现了这个问题。该代码在本地机器上运行良好,但在移动模拟器和我的 Windows Phone 上失败。
根据我的研究,SDK“SQLite for Universal Windows Platform”依赖于 SDK“Visual C++ 2015 Runtime for Universal Windows 平台应用程序 ”。
因此我们可能需要在使用 [=36= 时将 both "SQLite for Universal Windows Platform and "Visual C++ 2015 Runtime for Universal Windows Platform Apps" 添加到参考中]-PCL SQLite 的 NuGet 包。
如果只添加“SQLite for Universal Windows Platform”,我们会得到如下警告:
The SDK "SQLite.UWP.2015, Version=3.13.0" depends on the following SDK(s) "Microsoft.VCLibs, version=14.0", which have not been added to the project or were not found. Please ensure that you add these dependencies to your project or you may experience runtime issues. You can add dependencies to your project through the Reference Manager.
添加两个引用后,警告消失,问题得到解决。