使用自定义.dll文件生成无法解析引用"Windows.Foundation.UniversalApiContract"和其他错误



我目前正在为Hololens 2开发Unity应用程序。在这里,我想通过蓝牙向Hololens发送数据。为此,我制作了一个小型蓝牙库,并将其编译为.dll文件。然后我试图将这个.dll文件导入到我的资产中,但出现了多个错误:

Unable to resolve reference 'Windows.Foundation.UniversalApiContract'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference 'Windows.Foundation.FoundationContract'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference 'System.Runtime.WindowsRuntime'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.

我已经更新了SDK版本,并以最新版本为目标,但错误仍然存在。

之所以发生这种情况,是因为WinRT API仅在构建到通用Windows平台时可用,而在Unity编辑器中不可用。从Windows运行时使用API时,建议有条件地包含任何带有预处理器指令ENABLE_WINMD_SUPPORT定义的WinRT均衡代码。

有关如何在HoloLens的Unity项目中使用WinRT API的更多信息,请参阅此处:带Unity的HoloLen 的WinRT API

相关内容

最新更新