{"record":{"id":"16401873408f427e","repo":"dotnet/wpf","slug":"sr-parsertoomanyassemblies","errorCode":null,"errorMessage":"SR.ParserTooManyAssemblies","messagePattern":"SR\\.ParserTooManyAssemblies","errorType":"exception","errorClass":"XamlParseException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlRecords.cs","lineNumber":4349,"sourceCode":"            set\n            {\n                _flags[_typeIdLowSection] = (short)  (value & 0xff);\n                _flags[_typeIdHighSection] = (short) ((value & 0xff00) >> 8);\n            }\n        }\n\n        // Assembly id of the assembly where this type is defined.\n        // NOTE:  This is always positive in BAML files, but can be set\n        //        to -1 for known types when created programmatically.\n        internal short AssemblyId\n        {\n            get { return _assemblyId; }\n            set\n            {\n                // Make sure we don't intrude on the Flags portion of the assembly ID\n                if (_assemblyId > 0x0FFF)\n                {\n                    throw new XamlParseException(SR.ParserTooManyAssemblies);\n                }\n                _assemblyId = value;\n            }\n        }\n\n        // Fully qualified name of type, including namespace\n        internal string TypeFullName\n        {\n            get { return _typeFullName; }\n            set { _typeFullName = value; }\n        }\n\n        // Additional properties not stored in the baml stream\n\n        internal override BamlRecordType RecordType\n        {\n            get { return BamlRecordType.TypeInfo; }\n        }","sourceCodeStart":4331,"sourceCodeEnd":4367,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlRecords.cs#L4331-L4367","documentation":"AssemblyInfoRecord's AssemblyId property throws XamlParseException(SR.ParserTooManyAssemblies) when an assembly ID exceeds 0x0FFF (4095). The BAML format reserves the top bits of the 16-bit assembly ID for flags, so more than ~4095 distinct assembly references cannot be encoded.","triggerScenarios":"Compiling BAML that references more than 4095 distinct assemblies — each unique assembly reference consumed during writing gets a sequential ID in AssemblyId.","commonSituations":"Huge XAML projects or merged markup referencing an enormous closure of assemblies (control libraries, plugins, generated code) hitting the 12-bit ID limit during build.","solutions":["Reduce the number of assemblies referenced from XAML (consolidate control libraries, remove unused xmlns mappings)","Split the UI into multiple independently compiled projects to cap per-BAML assembly references","Audit xmlns/namespace imports for accidental assembly pulls (e.g. clr-namespace mapping huge assemblies)","If genuinely needed, this is a BAML format limit — escalate to the WPF team"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// track distinct assembly references during XAML compilation and fail early\nif (assemblyIds.Count >= 0x0FFF)\n    throw new InvalidOperationException(\"Too many assemblies referenced from XAML (limit 4095)\");","typeGuard":null,"tryCatchPattern":"try { CompileBaml(project); }\ncatch (XamlParseException ex) when (ex.Message.Contains(\"assemblies\")) {\n    log.Error(\"Reduce referenced assemblies in XAML below 4095\"); throw;\n}","preventionTips":["Consolidate control libraries","Prune unused xmlns/clr-namespace imports","Split very large XAML projects"],"tags":["wpf","baml","limit-exceeded","value-out-of-range"],"backgroundTag":"value-out-of-range","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}