Unity-Technologies/UnityCsReference · error · ArgumentException

Could not locate assembly for {name}

Error message

Could not locate assembly for {name}

What it means

The terminal fallthrough of GetLibrarySearchPaths: reached only when the function is neither in a development location nor in the deploy location that holds the assembly. It throws ArgumentException because no branch could locate the assembly for the given name.

Source

Thrown at Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:654

                var topLevel = il2CppFolder;
                if (customRoot != null)
                    topLevel = Path.Combine(topLevel, customRoot);

                var toolBinDirectory = Path.Combine(topLevel, name, "bin").ToNPath();
#pragma warning disable UA2001 // The Banned API Analyzer produces compile errors for any new Linq code. This pre-existing usage has been suppressed, but should be rewritten if possible.
                var candidates = toolBinDirectory.Files($"*{expectedToolExecutableName}", recurse: true)
#pragma warning restore UA2001
                    .Where(f => f.Parent.FileName == tfm)
                    .OrderByDescending(f => f.GetLastWriteTimeUtc())
                    .ToArray();

                if (candidates.Length == 0)
                    throw new InvalidOperationException($"{name} does not appear to be built in {il2CppFolder}");

                return candidates[0].Parent.ToString();
            }

            throw new ArgumentException($"Could not locate assembly for {name}");
        }

        internal static string ConstructBeeLibrarySearchPath()
        {
            var projectBinDirs = new[]
            {
                GetLibrarySearchPaths("Unity.Options", "netstandard2.0", "external/UnityOptions"),
                GetLibrarySearchPaths("Unity.Linker.Api", "netstandard2.0"),
                GetLibrarySearchPaths("Unity.IL2CPP.Api", "netstandard2.0"),
                GetLibrarySearchPaths("Unity.Api.Attributes", "netstandard2.0"),
                GetLibrarySearchPaths("Unity.IL2CPP.Bee.IL2CPPExeCompileCppBuildProgram.Data", "netstandard2.0"),
                GetLibrarySearchPaths("Unity.IL2CPP.Bee.BuildLogic", "net10.0"),
                // Now the quirky part.  We need to locate the platform build logic assemblies.
                // While il2cpp will have these during some build scenarios (IDE build or build.pl)
                // the project that will always have all of the is il2cpp-compile
                GetExePath("il2cpp-compile").ToNPath().Parent
            };

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Verify the IL2CPP deploy folder is intact and contains all required support assemblies (reinstall/repair the editor if missing).
  2. Check any custom IL2CPP folder override points to a valid deploy root.
  3. Ensure isDevelopmentLocation detection is correct for your setup; build the dev enlistment if you intend dev mode.

Example fix

/* no source edit */
// before: custom IL2CPP root missing Unity.Api.Attributes.dll
// after: restore the editor install or copy the deploy/lib contents
// so <deployRoot>/lib/netstandard2.0/Unity.Api.Attributes.dll exists
Defensive patterns

Strategy: validation

Validate before calling

if (!isDevelopmentLocation && !File.Exists(Path.Combine(GetDeployRoot(), "lib", tfm, name + ".dll")))
    throw new InvalidOperationException($"{name} assembly missing from deploy location; repair the editor install.");

Prevention

When it happens

Trigger: GetLibrarySearchPaths is called when isDevelopmentLocation is false AND the deploy branch does not contain the named assembly, OR the dev branch was skipped and no deploy path resolves. Functionally an unreachable-lookup state where the IL2CPP folder layout is unrecognized.

Common situations: Corrupt or partial editor install where the deploy folder lacks one of the required support DLLs; custom IL2CPP folder override pointing at a directory with neither dev nor deploy layout.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/8d5513a96678f78f. Report an issue: GitHub.