Search Unity

External Managed Assembly ARM64

Discussion in 'Editor & General Support' started by Gaulois94, Jan 22, 2020.

  1. Gaulois94

    Gaulois94

    Joined:
    Jan 24, 2018
    Posts:
    12
    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
     
    Last edited: Jan 22, 2020
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    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.
     
  3. Gaulois94

    Gaulois94

    Joined:
    Jan 24, 2018
    Posts:
    12
    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.
     
    Last edited: Jan 22, 2020
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    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.
     
  5. Gaulois94

    Gaulois94

    Joined:
    Jan 24, 2018
    Posts:
    12
    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
    <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
    None
    </ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
    Indeed, I got issues both with my <appName>.winmd, but also with Unity.winmd (from memory, I do not remember the exact filename).
    Best
     
    Last edited: Jan 28, 2020