Using .NET 4.6 features not supported by Unity WSA Build


We are facing an issue trying to use .NET 4.6.1 System.Numerics.Vectors in a HoloLens app. An UWP API we are calling is returning a System.Numerics.Vectors Vector2 and Vector3.

To be clear, the code is only enabled for the UWP/WSA platform, so disabled in the Editor Mono runtime itself, using #if NETFX_CORE
Still it fails during Build for WSA UWP 10 HoloLens in Unity:
"Reference rewriter: Error: method System.Numerics.Vector2 Windows.Media.Devices.Core.CameraIntrinsics::get_FocalLength() doesn’t exist in target framework "

I assume this is because the WinRT / UWP / WSA target in Unity does not use .Net 4.6.1 yet. We tried with Unity 5.5 and 5.6.
The workaround for now was to comment out the code in the script for Unity build and then to uncomment in VS when it’s actually build for the HL.

But that is not a great workflow at all, so what is the best way to enable that?

We also tried to use the System.Numerics.Vectors NuGet package PCL DLL in Assets\Plugins which works in Unity but then fails during actual build in VS due to duplicate references. No surprise.

Another idea would be to make an extra .Net DLL only with that code pieces using System.Numerics.Vectors and then to include that DLL in Assets\Plugins\WSA so Unity does not process the DLL further during its build. But that’s not a great approach.


I am facing the same issue right now, a year later. Have you managed to solve it somehow?



Unity 2017 should work with .NET 4.6 fine.