首页 > 解决方案 > 将 WPF 作为 UWP 运行时未找到 System.Data.SQLite dll

问题描述

我计划将我的 WPF 应用程序发布到 Microsoft Store。所以我按照这个链接来打包我的应用程序。

在访问SQLite db 时,我使用的是 SQLite Dev 团队开发的System.Data.SQLite lib。

当我将我的应用程序作为 WPF 执行时,一切正常,但是当我将我的应用程序作为 UWP 执行时,它会引发错误:

System.DllNotFoundException: Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op)
at System.Data.SQLite.SQLite3.StaticIsInitialized()
at System.Data.SQLite.SQLiteLog.Initialize(String className)
at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework)
at System.Data.SQLite.SQLiteConnection..ctor(String connectionString)
at eComEasy.Lib.Helper.LibUtility.InitiateDbSchema(String connString, String[] names)

我怎样才能解决这个问题?

注意:我设法创建了 db 文件,但是当我想创建 teble 时,出现了上述错误。

标签: c#wpfsqliteuwp

解决方案


尝试System.Data.SQLite从 NuGet 引用包:

Install-Package Microsoft.Data.SQLite -Version 2.1.0

或者在 Visual Studio 中使用NuGet 包管理器 UI(右键单击项目,选择Manage NuGet Packages for Solution...并搜索Microsoft.Data.SQLite.

如果它没有帮助,请尝试遵循SQLite 文档中的Using Native Library Preloading部分,尽管我不认为这是必要的。


推荐阅读