{"record":{"id":"e5c6bf52f623b8ab","repo":"Unity-Technologies/UnityCsReference","slug":"assembly-cannot-be-have-reserved-name-loadedcust","errorCode":null,"errorMessage":"Assembly cannot be have reserved name '{loadedCustomScriptAssembly.Name}'","messagePattern":"Assembly cannot be have reserved name '(.+?)'","errorType":"exception","errorClass":"AssemblyDefinitionException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Scripting/ScriptCompilation/LoadingAssemblyDefinition.cs","lineNumber":316,"sourceCode":"            Exceptions = exceptions.ToArray();\n        }\n\n        public void ClearCustomScriptAssemblies()\n        {\n            CustomScriptAssemblies = Array.Empty<CustomScriptAssembly>();\n            CustomScriptAssemblyReferences.Clear();\n        }\n\n        static void CheckPredefinedAssemblyNames(\n            HashSet<string> predefinedAssemblyNames,\n            Dictionary<string, CustomScriptAssembly> assemblyLowercaseNamesLookup,\n            string lowerCaseName,\n            Dictionary<string, List<string>> prefixToFilePathLookup,\n            ref CustomScriptAssembly loadedCustomScriptAssembly)\n        {\n            if (predefinedAssemblyNames.Contains(loadedCustomScriptAssembly.Name))\n            {\n                throw new AssemblyDefinitionException(\n                    $\"Assembly cannot be have reserved name '{loadedCustomScriptAssembly.Name}'\",\n                    loadedCustomScriptAssembly.FilePath);\n            }\n\n            if (assemblyLowercaseNamesLookup.TryGetValue(lowerCaseName, out var duplicate))\n            {\n                var filePaths = new[]\n                {\n                    loadedCustomScriptAssembly.FilePath,\n                    duplicate.FilePath\n                };\n                var errorMsg = $\"Assembly with name '{loadedCustomScriptAssembly.Name}' already exists\";\n                loadedCustomScriptAssembly = null; // Set to null to prevent it being added.\n                throw new AssemblyDefinitionException(errorMsg, filePaths);\n            }\n\n            // Check both asmdef and asmref files.\n            if (prefixToFilePathLookup.TryGetValue(loadedCustomScriptAssembly.PathPrefix,","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Scripting/ScriptCompilation/LoadingAssemblyDefinition.cs#L298-L334","documentation":"Thrown by CheckPredefinedAssemblyNames (LoadingAssemblyDefinition.cs:316) when an asmdef's 'name' matches an entry in predefinedAssemblyNames. That set is built from EditorBuildRules.PredefinedTargetAssemblyNames (Unity's built-in/predefined assemblies) plus, depending on the target framework, the .NET Framework / .NET Standard 2.1 reference assemblies. These names are reserved so user assemblies cannot shadow or alias the framework's own assemblies.","triggerScenarios":"Naming an asmdef \"UnityEngine\", \"UnityEditor\", \"mscorlib\", \"System\", \"System.Core\", \"netstandard\", or any other predefined/framework assembly name.","commonSituations":"Accidentally naming a wrapper assembly after the framework it wraps. Package naming collisions with BCL assemblies. Copying internal Unity assembly names into a project.","solutions":["Rename the asmdef to a value not present among predefined/framework assembly names (prefix with your company/package name).","If the name was chosen to 'replace' a built-in assembly, that is unsupported; instead reference the built-in assembly and extend it."],"exampleFix":"// before (.asmdef)\n{ \"name\": \"System\" }\n// after\n{ \"name\": \"MyCompany.SystemExtensions\" }","handlingStrategy":"validation","validationCode":"// Reject reserved/framework assembly names before importing\nstatic readonly HashSet<string> Reserved = new HashSet<string>(StringComparer.OrdinalIgnoreCase)\n{\n    \"UnityEngine\",\"UnityEditor\",\"mscorlib\",\"System\",\"System.Core\",\"System.Xml\",\n    \"netstandard\",\"System.Net.Http\"\n};\n\nif (Reserved.Contains(data.name))\n    throw new InvalidOperationException(\n        $\"'{data.name}' is a reserved/framework assembly name; rename it.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefix asmdef names with a company/package namespace.","Never name an asmdef after a BCL or built-in Unity assembly.","Cross-check candidate names against EditorBuildRules.PredefinedTargetAssemblyNames when authoring tooling."],"tags":["unity","asmdef","script-compilation","naming","reserved","config"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}