移动模拟器 Windows 10 的 SQLite UWP 错误 [英] SQLite UWP Error with Mobile EMulator Windows 10

查看:22
本文介绍了移动模拟器 Windows 10 的 SQLite UWP 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试编译和运行 VS 2015 UWP 应用程序时运行移动模拟器时遇到以下错误.使用本地机器或模拟器时,应用程序运行良好.

I am getting the following error when I run the Mobile Emulator while trying to compile and run a VS 2015 UWP app. The app runs fine when using the Local Machine or Simulator.

   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 的 SQLitesqlite-net-pcl适用于通用 Windows 的 Microsoft Visual C++ 2013 运行时包

I have the following references: SQLite for Universal Windows 3.9.1 sqlite-net-pcl Microsoft Visual C++ 2013 Runtime Package for Universal Windows

using (var db......:

The code where the error occurs in the "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.

I see a number of similar posts, but some are dated and not using the most recent SQLite libs and pcls.

我正在寻找正确的 SQLite dll、sqlite pcls、运行时(例如 VC++ 2013?以及可用于在本地计算机和手机模拟器上编译和运行 UWP 应用程序的版本号.

I'm looking for the correct SQLite dlls, sqlite pcls, runtimes (e.g. VC++ 2013? And version numbers that can be used to compile and run a UWP app on both the local machine and phone emulator.

TIA

推荐答案

以下是我使用 SQLite 的方式:

Following is how I work with SQLite:

创建一个新的空白 c# 通用 Windows 平台应用程序.

Create a new blank c# Universal Windows Platform app.

右键单击项目的引用 -> 添加引用 -> 通用 Windows -> 扩展 -> 为通用应用平台添加 SQLite 及其依赖 Visual C++ 2015 Runtime for Universal Windows

Right click on the References of project -> Add Reference -> Universal Windows -> Extension -> add SQLite for Universal App Platform and its dependency Visual C++ 2015 Runtime for Universal Windows

项目节点右键->管理NuGet包->搜索SQLite.Net-PCL->安装默认版本3.0.5

Right click on the project node -> Manage NuGet packages -> Search SQLite.Net-PCL -> Install the default version 3.0.5

将您的代码更改为以下内容:

Change your code to the following:

using (var db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath))
{
    ...
}

这篇关于移动模拟器 Windows 10 的 SQLite UWP 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆