2
votes

I want to use the some classes of the System.Numerics assembly in my own DLL project which is used in some other projects too. But I run into problems with Unity3D targeting UWP Hololens. In editor it works out of the box but when I build the project Unity complains
error CS7069: Reference to type 'Vector3' claims it is defined in 'System.Numerics', but it could not be found

I copied System.Numerics.Vector.DLL from Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.7.1-api. 4.7.1 should be the one according to this Unity blog post. I tried out different versions (even 4.5) but it does not work either.

My own DLL uses 4.7.1 as well (tried 4.6.1 at the beginning). Now the editor complains that Loading script assembly "Assets/DLLs/System.Numerics.Vectors.dll" failed!. Thus I excluded the editor platform.

As next I tried using System.Numerics.dll (i.e. not just the Vectors). Now the results are even stranger:
CS0433: The type 'Vector3' exists in both 'System.Numerics.Vectors ... System.Numerics.

My own DLL is completely in plain old C#, nothing special, no file access, ...

So how can I do this? Yes I know there is Vector3D class in Unity :) But I need to build a DLL that is used outside Unity.


Update:

I removed all direct calls to System.Numeric namespace classes. Now the UWP solution builds but with a bunch of post-processing errors: Reference rewriter: Error: type 'System.Numerics.Vector3' doesn't exist in target framework. It is referenced from ARSceneSerialization.dll at ARSceneSerialization.ARKeyFrame.

I think this sounds bad.

1
i you try the 4.5 version at MonoBleedingEdge\lib\mono\4.5? - Programmer
I had and just repeated it witout success: One DLL (System.Numerics) but the _ exists in both_ message - Kay
@Programmer (forgot the @ in the last message) I guess it's a Unity UWP specific problem, simply not supporting System.Numerics.DLL on this platform - Kay
Can you you try to build for Windows standalone? No UWP this time and see if there is an issue - Programmer
Interesting. I suspect that the issue is how you built the DLL. I am not entirely sure since I haven't made a build for Hololens. Before you build your dll, add C:\Program Files\Unity\Editor\Data\Managed\UnityEngine.dll reference to it but going to Project > Add Reference > Browse. Also, add the System.Numerics reference it in MonoBleedingEdge\lib\mono\4.5. Now, try to build it. If you still get errors, delete those System.Numerics and System.Numerics.Vectors from your project and try again - Programmer

1 Answers

0
votes

Unity cannot find the assembly because of the folder name in which you placed the DLL

According to Unity Docs

Always place plug-ins in a folder called Plugins for them to be detected by Unity.