MRTK and Microsoft Azure SignalR dlls having the same class names causing error in unity editor.

Microsoft

 I need to use microsoft azure singalR for a UWP that is deployed to the hololens2. I gathered all of the dlls for the package(40 of them and it was miserable work lol) but after adding them to my plugins folder one of the dlls "System.Numeric.Vectors" is conflicting with the MRTK library. They both share classes with the same name and the Unity editor is having trouble knowing which library to pull from. The error given is below -


Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec\Core\Extensions\SystemNumericsExtensions.cs(21,71): error CS0433: The type 'Vector3' exists in both 'System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec\Core\Extensions\SystemNumericsExtensions.cs(33,85): error CS0433: The type 'Quaternion' exists in both 'System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec\Core\Extensions\SystemNumericsExtensions.cs(38,74): error CS0433: The type 'Matrix4x4' exists in both 'System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

All these classes are in the same file in the MRTK. I have not been able to resolve this issue. I have tried to get unity to use one library over the other to resolve the issue but so far not luck. Have you guys or anyone else ran into a similar issue with MRTK and dlls sharing the same name for classes and how to fix the issue??

thank you

1 Reply

One potential solution to this issue is to use "extern alias" directives in your code to differentiate between the conflicting class names. This allows you to specify which library to use for a particular class, instead of relying on Unity to resolve the conflict automatically.

To use "extern alias" directives, you will need to perform the following steps:

Add the following line at the top of your C# script to specify the alias for the Microsoft Azure SignalR DLL:
csharp
Copy code
extern alias AzureSignalR;
Whenever you reference a class from the Microsoft Azure SignalR DLL, add the alias before the class name, like this:
arduino
Copy code
AzureSignalR::Vector3 myVector = new AzureSignalR::Vector3();
This tells the compiler to use the "AzureSignalR" alias to resolve the class name, instead of relying on the default behavior of the compiler.

By using "extern alias" directives, you can avoid conflicts between class names in different DLLs and ensure that your code uses the correct version of each class.

I hope this helps you resolve the issue:smile: and continue working with MRTK and Microsoft Azure SignalR in Unity.