- Home /
Unable to use System.Numerics in Unity 2017
I'm trying to use System.Numerics - this was added in C#4 so theoretically now available in Unity 2017 with the 4.6 support. It's turning out to be stupidly difficult to actually make this work.
In order for the Unity Editor to compile a mcs.rsp file in the Assets folder is required, contents:
-r:System.Numerics
Then reimporting the script or reopening the project will find System.Numerics.
Opening up VS will show code errors however until you manually add a reference to System.Numerics. But ... if you try to build / attach to Unity from VS Unity will remove the reference and the build will fail in VS.
Does anyone have a solution for stopping this happening? Or a simpler solution to getting both Unity and VS to be able to build a project including System.Numerics?
Answer by Bunny83 · Jul 18, 2017 at 01:12 AM
Of course the solution is, like with any external assembly, to physically copy the assembly into your project. You should find it somewhere around here:
C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.5\
You can't simply "add a reference" to an external assembly. Everything that your application is using has to be part of the application. Unlike actual managed applications written for the .NET framework, Unity doesn't require the user to have .NET / Mono installed.
ps: You don't have to do anything with a mcs.rsp file. Unity automatically creates the C# project and add all references for all assemblies in your project.
Arg, this totally fixed all the issues. THAN$$anonymous$$ YOU. The mcs.rsp file was given to me as the solution by a Unity employee (ugh) and previously when I'd tried to copy in the Numerics.dll I was copying from "C:\Program Files (x86)\Reference Assemblies\$$anonymous$$icrosoft\Framework.NETFramework\v4.6" which gives a 'failed to load' error in the Unity Editor ... the 4.5 version also shows the same error so no idea what's magical about the monobleedingedge version!
Well, it's simply the mono version of that assembly. $$anonymous$$eep in $$anonymous$$d that $$anonymous$$ono is a complete recreation of the .NET framework. It aims to be fully compatible with .NET but it only is 98% compatible -.-. When you want to include framework assemblies you should first look for them in the $$anonymous$$ono folders that are shipped with Unity.
Answer by elenzil · Jul 21, 2021 at 07:52 PM
On the chance you're developing a UWP app, be sure your build platform is set to UWP.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Multiple plugins with the same name 0 Answers
How to get Scene Name in Edit Mode without #if UNITY_EDITOR 1 Answer