我在尝试编译和运行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()
Run Code Online (Sandbox Code Playgroud)
我有以下参考:SQLite for Universal Windows 3.9.1 sqlite-net-pcl Microsoft Visual C++ 2013 Runtime Package for Universal Windows
"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());
}
}
Run Code Online (Sandbox Code Playgroud)
我看到了许多类似的帖子,但有些是过时的,没有使用最新的SQLite库和pcls.
我正在寻找正确的SQLite dll,sqlite pcls,运行时(例如VC++ 2013?以及可用于在本地计算机和手机模拟器上编译和运行UWP应用程序的版本号.
TIA
以下是我如何使用SQLite:
从http://sqlite.org/download.html下载并安装Sqlite visual studio扩展
创建一个新的空白c#通用Windows平台应用程序.
右键单击项目的引用 - >添加引用 - >通用Windows - >扩展 - >为通用应用程序平台添加SQLite及其依赖项Visual C++ 2015 Runtime for Universal Windows
将您的代码更改为以下内容:
using (var db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath))
{
...
}
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
2852 次 |
最近记录: |