Unity-Technologies/UnityCsReference · error · NotImplementedException
Use of reference assemblies is always enabled
Error message
Use of reference assemblies is always enabled
What it means
ScriptCompilerOptions.EmitReferenceAssembly is marked [Obsolete(..., true)] and both getter and setter throw NotImplementedException unconditionally — reference assemblies are now always enabled and the property is hard-banned. Any read or write of it throws at runtime (and is a compile error for new code).
Source
Thrown at Editor/Mono/Scripting/ScriptCompilation/CompilationPipeline.cs:46
[Flags]
public enum RequestScriptCompilationOptions
{
None,
CleanBuildCache
}
public class ScriptCompilerOptions
{
public string RoslynAnalyzerRulesetPath { get; set; }
public string[] RoslynAnalyzerDllPaths { get; set; }
public string[] RoslynAdditionalFilePaths { get; set; }
public string AnalyzerConfigPath {get; set;}
public bool AllowUnsafeCode { get; set; }
[Obsolete("Use of reference assemblies is always enabled", true)]
public bool EmitReferenceAssembly
{
get { throw new NotImplementedException("Use of reference assemblies is always enabled"); }
set { throw new NotImplementedException("Use of reference assemblies is always enabled"); }
}
internal bool UseDeterministicCompilation { get; set; }
public string[] AdditionalCompilerArguments { get; set; }
public CodeOptimization CodeOptimization { get; set; }
public ApiCompatibilityLevel ApiCompatibilityLevel { get; set; }
public EditorAssembliesCompatibilityLevel EditorAssembliesCompatibilityLevel { get; set; }
public string[] ResponseFiles { get; set; }
public string LanguageVersion { get; internal set; } // Requires a refresh sent to the Code Editor package if made public
public ScriptCompilerOptions()
{
AllowUnsafeCode = false;
ApiCompatibilityLevel = ApiCompatibilityLevel.NET_Unity_4_8;
EditorAssembliesCompatibilityLevel = EditorAssembliesCompatibilityLevel.Default;
ResponseFiles = Array.Empty<string>();
RoslynAnalyzerDllPaths = Array.Empty<string>();View on GitHub (pinned to 225b0fbdb5)
Solutions
- Remove all uses of EmitReferenceAssembly from your code; reference assemblies are always on.
- Upgrade packages that still reference the obsolete property.
Example fix
// before options.EmitReferenceAssembly = true; // after // (remove the line; reference assemblies are always enabled)
Defensive patterns
Strategy: fallback
Validate before calling
// There is nothing to validate: the property always throws. // Remove the call site entirely; reference assemblies are mandatory.
Prevention
- Delete all references to EmitReferenceAssembly from your code and dependencies.
- Watch for compiler obsolete-as-error warnings when upgrading packages that touched it.
When it happens
Trigger: Reading or writing ScriptCompilerOptions.EmitReferenceAssembly (the property always throws NotImplementedException).
Common situations: Legacy code or a third-party package that toggled reference assembly emission before it became mandatory.
Related errors
- AA is not supported on GUIViews
- GetRenderersFilteringResults(ReadOnlySpan<int>) is obsolete.
- GetRenderersHiddenResultBits(ReadOnlySpan<int>) is obsolete.
- EditorApplication.OpenScene() cannot be called when in the U
- CompileCSharp is no longer supported. Use UnityEditor.Compil
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/35a34b98bb241de0.
Report an issue: GitHub.