在构建一个添加了 SQLite 的 UWP 应用程序时,我收到了大约 40 条警告,如下所示(只是方法名称发生了变化)(添加了一些新行以提高可读性)。配置设置为发布。我在 Debug模式下没有收到任何这些消息。
C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\ARM\ilc\IlcInternals.targets(936,5):
warning : ILTransform_0000:
MCG : warning MCG0006:
Unresolved P/Invoke method 'Open!sqlite3' in assembly
'SQLite.Net.Platform.WinRT, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null'
because it is not available in UWP applications. Please either use an another API ,
or use [DllImport(ExactSpelling=true) to indicate that you understand the
implications of using non-UWP application APIs.
根据许多教程,我在项目中有以下引用。
SQLite for Windows Universal Platform
通过来自 sqlite.org 的 sqlite-uwp-3120200.vsix 文件安装Visual C++ 2015 Runtime for Universal Windows Platform Apps
(尝试使用和不使用此扩展,因为一些教程在是否需要添加方面存在差异)SQLite.Net-PCL
(v3.1.1) 通过 NuGet 安装
它的目标版本和最小版本是 10586。由于它是在 Release模式下构建的,因此启用了 native 工具链的使用。
有谁知道这条警告信息是什么意思以及如何解决?
最佳答案
我在处理 UWP 单元测试时遇到了类似的问题 - 在 Debug模式下没有问题,只有在 Release模式下。
我通过将 UseDotNetNativeToolchain 更改为 false 解决了这个问题。
查看您的 .vcxproj 文件
<UseDotNetNativeToolchain>false</UseDotNetNativeToolchain>
关于c# - 使用 SQLite 构建 UWP 应用时出现 P/Invoke 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37514665/