C# 移动仿真器Windows 10的SQLite UWP错误
当我试图编译和运行VS 2015 UWP应用程序时,运行Mobile Emulator时出现以下错误。当使用本地机器或模拟器时,应用程序运行良好C# 移动仿真器Windows 10的SQLite UWP错误,c#,sqlite,uwp,C#,Sqlite,Uwp,当我试图编译和运行VS 2015 UWP应用程序时,运行Mobile Emulator时出现以下错误。当使用本地机器或模拟器时,应用程序运行良好 System.TypeInitializationException was unhandled by user code HResult=-2146233036 Message=The type initializer for 'SQLitePCL.raw' threw an exception. Source=SQLitePCL.
System.TypeInitializationException was unhandled by user code
HResult=-2146233036
Message=The type initializer for 'SQLitePCL.raw' threw an exception.
Source=SQLitePCL.raw
TypeName=SQLitePCL.raw
StackTrace:
at SQLitePCL.raw.sqlite3_open_v2(String filename, sqlite3& db, Int32 flags, String vfs)
at SQLite.SQLiteConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks)
at SQLite.SQLiteConnection..ctor(String databasePath, Boolean storeDateTimeAsTicks)
at App3.MainPage.LoadSQLData()
at App3.MainPage..ctor()
at App3.App3_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage()
at App3.App3_XamlTypeInfo.XamlUserType.ActivateInstance()
InnerException:
HResult=-2146233052
Message=Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Source=SQLitePCL.raw
TypeName=""
StackTrace:
at SQLitePCL.SQLite3Provider.NativeMethods.sqlite3_win32_set_directory(UInt32 directoryType, String directoryPath)
at SQLitePCL.SQLite3Provider..ctor()
at SQLitePCL.raw..cctor()
我有以下参考资料:
SQLite for Universal Windows 3.9.1
sqlite网络pcl
微软Visual C++ 2013通用Windows下的运行包
“使用(var db…”中出现错误的代码:
int recCtr = 0;
var root = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "BaseBallOU.db");
List<string> NHLCollection = new List<string>();
using (var db = new SQLite.SQLiteConnection(dbPath))
{
var NHLlist = db.Table<Teams>().ToList();
foreach (var item in NHLlist)
{
recCtr++;
NHLCollection.Add(item.TeamName.ToString());
}
}
int recCtr=0;
var root=Windows.Storage.ApplicationData.Current.LocalFolder.Path;
var dbPath=Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,“BaseBallOU.db”);
List NHLCollection=新列表();
使用(var db=new SQLite.SQLiteConnection(dbPath))
{
var NHLlist=db.Table().ToList();
foreach(NHLlist中的var项目)
{
recCtr++;
添加(item.TeamName.ToString());
}
}
我看到了许多类似的帖子,但其中一些是过时的,没有使用最新的SQLite LIB和PCL
我正在寻找正确的SQLite DLL、SQLite PCL、运行时(例如VC++2013)以及可用于在本地计算机和电话仿真器上编译和运行UWP应用程序的版本号
TIA以下是我如何使用SQLite的:
using (var db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath))
{
...
}
步骤1:使用Visual Studio 2015安装用于通用Windows平台开发的SQLite VSIX软件包 步骤2:安装NuGet软件包SQLite.NET-PCL PM>安装程序包SQLite.NET-PCL 步骤3:添加引用 添加参考->通用窗口->扩展->确保已检查以下软件包: “用于通用Windows平台的SQLite” “Visual C++ 2015运行时通用Windows平台应用程序”
如果您没有为VC++2015运行时添加引用,则在创建数据库连接时会出现一个错误,其中提到“无法在SQLite Net Platform WinRT中加载DLL‘sqlite3’。您是否尝试使用正确的WinRT平台设置?
使用(SQLiteConnection conn=new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT()),dbPath))
我的示例仍然有效(在本地计算机和仿真器上试用)Alan,我按照您的示例一步一步地进行操作,在本地计算机和Emulator X86/Debug试用中都收到了以下错误消息。System.DllNotFoundException未由用户代码HResult=-2146233052 message=无法加载DLL“sqlite3”:找不到指定的模块。(HRESULT的异常:0x8007007E)Source=SQLite.Net.Platform.WinRT TypeName=”“emulatorest1.emulatorest1_XamlTypeInfo.XamlUserType.ActivateInstance()InnerException:我也有同样的问题,因为我遵循相同的步骤,知道吗?问题是否发生在一个空白的项目中?如果是,请检查您的VS更新以确保您没有遇到任何已知的工具问题。我还尝试了另一个NuGet包“sqlite net pcl”,它似乎不需要其他包。