External Managed Assembly ARM64

Hi guys,

I am trying to embed a managed assembly build using Visual Studio to work with Unity for ARM64 platforms (HoloLens 2).
To compile the managed assembly, Visual Studio requires to use at least the version 16299 (Fall Creator Update).

However, if I use this version, Unity 2019.2.17f1. yields that error when trying to build a IL2CPP project:

Assets\Scripts\Unity\HandDetectorProvider.cs(78,36): error CS1705: Assembly ‘HandDetector’ with identity ‘HandDetector, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ uses ‘System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ which has a higher version than referenced assembly ‘System.Runtime’ with identity ‘System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’

Using a managed assembly (compiled for ARM32) with minimal version = 15063 works like a charm (no more errors), but the boost of performance that 64bits architectures propose is almost a requirement for my project…

Anything to solve that issue? (like updating something internal to Unity)?

Thank you!

Best

The System.Runtime assembly is from .NET Core, which Unity does not support. Try to compile the HandDetector assembly against .NET Standard 2.0 or .NET Framework 4.7.1 - that should work.

The only issue I have is that I am using Windows MediaFoundation API, so I need the namespace Windows which is in .NET Core I guess.
Moreover, since I can use managed assembly in v15063, it seems that Unity handles a part of System.Runtime.

After few research, Unity does handle managed assembly compiled with .NET Core (hence the place of place holders). I guess I have to wait Unity to update their editor so they will use a more recent System.Runtime version.

You can still reference those APIs if you target .NET Standard 2.0 or .NET Framework and just add a reference to Windows.winmd from the Windows SDK.

Also, you should be building your managed DLLs for AnyCPU target, as Unity doesn’t really support architecture specific managed DLLs.

I was able to compile, run the code, and even find bugs that did not show in x86/ARM32 architectures, thank you so much!
Just a tiny thing though: this should maybe be automatically added into the .csproj generated

None

Indeed, I got issues both with my .winmd, but also with Unity.winmd (from memory, I do not remember the exact filename).
Best