sqllite3.dll与移动设备的UWP应用开发问题

时间:2017-02-18 02:23:13

标签: sqlite uwp windows-10-universal

我正在尝试学习如何为桌面和移动设备开发UWP应用程序。我一直在努力让实体框架在我的应用程序中工作以存储应用程序状态,并遵循以下链接:

https://docs.microsoft.com/en-us/ef/core/get-started/uwp/getting-started

它适用于Desktop,但问题是当我尝试在Windows Mobile模拟器上运行它时,当代码到达db.Database.Migrate()步骤时,我在调试模式下出现以下错误:

Unable to load DLL 'sqlite3': The specified module could not be found

在我上面粘贴的链接中,其他人遇到了同样的问题,并在评论中建议他们尝试以下操作:

Step 1: Install SQLite VSIX pacakge for Universal Windows Platform development using Visual Studio 2015
https://www.sqlite.org/2016/sqlite-uwp-3130000.vsix

Step 2: Install NuGet package SQLite.NET-PCL
Install-Package SQLite.NET-PCL

Step 3: Add references
Add Reference -> Universal Windows ->Extensions -> Make sure the following packages have been checked: "SQLite for Universal Windows Platform" "Visual C++ 2015 Runtime for Universal Windows Platform Apps"
After that, if you get the error "Payload contains two or more files with the same destination path 'sqlite3.dll', do the following:
copy sqlite3.dll from 
C:\Program Files (x86)\Microsoft SDKs\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UAP.2015\3.8.11.1\Redist\Debug\ARM\sqlite3.dll
past to (override it)
C:\Users\%USERNAME%\.nuget\packages\SQLitePCL.raw_basic\0.7.1\build\native\sqlite3_dynamic\winrt81\arm\sqlite3.dll

执行这些步骤后的问题是,我现在正在为#34生成一个问题; Payload包含两个或更多文件"但是不在SQLitePCL.raw_basic目录中(我甚至看起来都没有)。相反,我的错误如下:

Payload contains two or more files with the same destination path 'sqlite3.dll'. Source files: 
C:\Users\admin\.nuget\packages\SQLite\3.13.0\runtimes\win7-x86\native\sqlite3.dll
C:\Program Files (x86)\Microsoft SDKs\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UWP.2015\3.13.0\Redist\Debug\x86\sqlite3.dll

我一直在各处搜索,我真的很难过如何让我的UWP程序在Mobile上运行。非常感谢你的帮助!

1 个答案:

答案 0 :(得分:0)

似乎你从@Leandro_Medeiros_Machado对this document的评论中找到了解决异常The specified module could not be found的解决方案。如果在完成上述三个步骤后遇到Payload contains two or more files with the same destination path 'sqlite3.dll'异常,您也可以从评论中找到下一个解决方案。

  

之后,如果您收到错误“Payload包含两个或多个具有相同目标路径'sqlite3.dll'的文件,请执行以下操作:从以下位置复制sqlite3.dll   C:\Program Files (x86)\Microsoft SDKs\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UAP.2015\3.8.11.1\Redist\Debug\ARM\sqlite3.dll   过去(覆盖它)   C:\Users\%USERNAME%\.nuget\packages\SQLitePCL.raw_basic\0.7.1\build\native\sqlite3_dynamic\winrt81\arm\sqlite3.dll

对于您,您可能需要复制 C:\Program Files (x86)\Microsoft SDKs\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UWP.2015\3.13.0\Redist\Debug\x86\sqlite3.dll到(覆盖)C:\Users\admin\.nuget\packages\SQLite\3.13.0\runtimes\win7-x86\native\sqlite3.dll

但实际上,对于使用EF核心,您不需要上述步骤,我建议您检查您的环境,而不是使用上述解决方法。我按照文档创建了一个简单的EF项目,没有安装VSIX,我可以在模拟器上成功运行(build 10586)。我的VS build是2015 update 3,我的OS版本是build 14393,EF核心版本是Microsoft.EntityFrameworkCore.Sqlite 1.1.0。因此,请首先检查您的环境是否符合以下要求:

如果你的EF核心和EF核心工具版本是正确的。