【发布时间】:2016-01-24 01:03:02
【问题描述】:
当我在尝试编译和运行 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.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()
我有以下参考资料: 通用 Windows 3.9.1 的 SQLite sqlite-net-pcl 适用于通用 Windows 的 Microsoft Visual C++ 2013 运行时包
在"using(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());
}
}
我看到许多类似的帖子,但有些过时了,并且没有使用最新的 SQLite 库和 pcls。
我正在寻找正确的 SQLite dll、sqlite pcls、运行时(例如 VC++ 2013?以及可用于在本地计算机和手机模拟器上编译和运行 UWP 应用程序的版本号。
TIA
【问题讨论】:
-
您是否尝试使用正确的 WinRT 平台设置?
using (SQLiteConnection conn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath))我的示例仍然有效(在本地机器和模拟器上试过)igrali.com/2015/05/01/using-sqlite-in-windows-10-universal-apps