Unity-Technologies/UnityCsReference · critical · ArgumentException

Could not map typename 'GameManager' to type info (initializ

Error message

Could not map typename 'GameManager' to type info (initializing code stripping utils)

What it means

ArgumentException thrown by the GameManagerTypeInfo property when UnityType.FindTypeByName("GameManager") returns null during code stripping initialization. This indicates the Unity native type registry does not contain a 'GameManager' type descriptor, which is expected to exist in all Unity editor builds. The property is lazily cached and decorated with NoAutoStaticsCleanup to persist across domain reloads.

Source

Thrown at Editor/Mono/BuildPipeline/AssemblyStripper.cs:218

            if (!oneOrMoreItemsWritten)
                return null;

            var path = linkerInputDirectory.Combine("SerializedTypes.xml");
            path.WriteAllText(sb.ToString());
            return path;
        }

        [NoAutoStaticsCleanup] // lazy cache of a native UnityType descriptor (FindTypeByName), stable across code reloads
        private static UnityType s_GameManagerTypeInfo = null;
        internal static UnityType GameManagerTypeInfo
        {
            get
            {
                if (s_GameManagerTypeInfo == null)
                {
                    UnityType result = UnityType.FindTypeByName("GameManager");
                    if (result == null)
                        throw new ArgumentException(string.Format("Could not map typename '{0}' to type info ({1})", "GameManager", "initializing code stripping utils"));
                    s_GameManagerTypeInfo = result;
                }

                return s_GameManagerTypeInfo;
            }
        }

        internal static void UpdateBuildReport(LinkerToEditorData dataFromLinker, StrippingInfo strippingInfo)
        {
            foreach (var moduleInfo in dataFromLinker.report.modules)
            {
                strippingInfo.AddModule(moduleInfo.name);
                foreach (var moduleDependency in moduleInfo.dependencies)
                {
                    strippingInfo.RegisterDependency(StrippingInfo.ModuleName(moduleInfo.name), moduleDependency.name);

                    if (!string.IsNullOrEmpty(moduleDependency.icon))
                        strippingInfo.SetIcon(moduleDependency.name, moduleDependency.icon);

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Restart the Unity editor to ensure the native type registry is fully initialized.
  2. Verify the Unity installation is complete and not corrupted — reinstall Unity if necessary.
  3. If running in batch mode, ensure all required modules are loaded before triggering a build.
  4. Check for Unity version mismatches between editor DLLs and native binaries.
  5. Report as a Unity bug if it occurs on a clean, standard installation.
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    var typeInfo = AssemblyStripper.GameManagerTypeInfo;
}
catch (ArgumentException ex) when (ex.Message.Contains("GameManager"))
{
    Debug.LogError("Unity type registry not initialized. Restart the editor. " + ex.Message);
}

Prevention

When it happens

Trigger: Accessing AssemblyStripper.GameManagerTypeInfo when the native type registry is not fully initialized or is missing the GameManager type. Occurs during build player operations that invoke code stripping (IL2CPP/managed stripping) before the editor's native type table is populated.

Common situations: Editor startup race conditions where stripping is triggered before all native types are registered, corrupted or incomplete Unity installation missing native modules, custom or stripped editor builds that exclude GameManager, version mismatches between editor modules, headless batch-mode builds with incomplete type initialization.

Related errors


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