I'm currently developing a Unity app for the Hololens 2. Here I want to send data to the Hololens through Bluetooth. To do this I have made a small Bluetooth library and compiled this into a .dll file. I then tried to import this .dll file into my assets, but multiple errors occur:
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.
I have updated the SDK version and have targeted the newest all around, but the error persists.
This happens because the WinRT API is only available when building to Universal Windows Platform, and it’s not available in Unity Editor. When using the API from Windows Runtime, it’s advisable to conditionally include any WinRT-leveraged code with preprocessor directive ENABLE_WINMD_SUPPORT define.
For more information about how to make use of WinRT APIs in your Unity project for HoloLens please refer to here: WinRT APIs with Unity for HoloLens