By default, Unity references the following assemblies when your project uses the .NET Framework API compatibility level:
mscorlib.dll
System.dll
System.Core.dll
System.Runtime.Serialization.dll
System.Xml.dll
System.Xml.Linq.dll
If your Unity project uses a part of the .NET class library API that Unity doesn’t compile by default, you can provide the C# compiler with a list of additional assemblies to reference during compilation.
To reference any other class library assemblies, you can create a response (.rsp) file with a list of command-line arguments to pass to the C# compiler as follows:
csc.rsp
in the Assets
folder of your Unity project.Assets
folder of your project, if they aren’t already in this folder.csc.rsp
file with command-line arguments for the assemblies you want to reference.For example, if your project uses the HttpClient
class, which is defined in the System.Net.Http.dll
assembly, the C# compiler might produce this initial error message if the assembly isn’t present:
The type `HttpClient` is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
To resolve this error, add a csc.rsp
file that contains the following command-line argument to the project:
-r:System.Net.Http.dll
Add a new line with the appropriate command-line argument for each assembly you want to reference.
Important: If you change from .NET Framework to .NET Standard and your csc.rsp
file references an assembly that doesn’t exist in .NET Standard, then compilation fails. To solve the issue, edit the csc.rsp
file to remove any references to assemblies that are exclusive to the .NET Framework profile before you change to .NET Standard.