{"record":{"id":"78967c63df023495","repo":"dotnet/wpf","slug":"sr-unrecognizedbamlnodetype","errorCode":null,"errorMessage":"SR.UnRecognizedBamlNodeType","messagePattern":"SR\\.UnRecognizedBamlNodeType","errorType":"exception","errorClass":"XamlParseException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Globalization/BamlResourceDeserializer.cs","lineNumber":170,"sourceCode":"                            AddChildToCurrentParent(bamlNode);\n                            break;\n                        }\n                    case BamlNodeType.EndConstructor:\n                        {\n                            BamlTreeNode bamlNode = new BamlEndConstructorNode();\n                            AddChildToCurrentParent(bamlNode);\n                            break;\n                        }\n                    case BamlNodeType.EndDocument:\n                        {\n                            BamlTreeNode bamlNode = new BamlEndDocumentNode();\n                            AddChildToCurrentParent(bamlNode);\n                            PopStack();\n                            break;\n                        }\n                    default:\n                        {\n                            throw new XamlParseException(SR.Format(SR.UnRecognizedBamlNodeType, _reader.NodeType));\n                        }\n                }\n\n                // read properties if it has any.\n                if (_reader.HasProperties)\n                {\n                    // The Hashtable is used to auto-number repeated properties. The usage is as the following:\n                    // When encountering the 1st occurrence of the property, it stores a reference to the property's node (BamlTreeNode).\n                    // When encountering the property the 2nd time, we start auto-numbering the property including the 1st occurrence\n                    // and store the index count (int) in the slot from that point onwards.                                         \n                    propertyOccurrences.Clear();\n\n                    _reader.MoveToFirstProperty();\n                    do\n                    {\n                        switch (_reader.NodeType)\n                        {\n                            case BamlNodeType.ConnectionId:","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Globalization/BamlResourceDeserializer.cs#L152-L188","documentation":"While reading the main BAML node loop, LoadBamlImp hits a BamlNodeType it does not recognize and throws this XamlParseException. The deserializer supports a fixed node set; an unknown node type indicates corrupt, truncated, or newer-version BAML.","triggerScenarios":"BAML stream contains a node type outside the set handled by the switch (e.g. produced by a newer WPF version or corrupted bytes), encountered mid-deserialization in LoadBamlImp.","commonSituations":"Version mismatch: BAML compiled by a newer framework parsed by an older one; damaged satellite assembly; custom tooling rewriting BAML bytes incorrectly.","solutions":["Use a .NET/WPF runtime version equal to or newer than the one that compiled the BAML","Recompile the resources so the BAML matches the runtime","Replace the corrupted resource assembly from a known-good build","Avoid third-party tools that rewrite BAML streams"],"exampleFix":"// before\n// running .NET Framework 3.5 parsing BAML from .NET 4.8 build\n// after\n// upgrade target framework / rebuild resources with matching toolchain","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { tree = deserializer.LoadBaml(); } catch (XamlParseException ex) when (ex.Message.Contains(\"UnRecognizedBamlNodeType\")) { log.LogError(ex); throw new ResourceLoadException(\"BAML version/corruption issue\", ex); }","preventionTips":["Match runtime framework version to the BAML compiler version","Rebuild resources after framework upgrades","Restore resource assemblies from known-good builds"],"tags":["baml","xaml","localization","version-mismatch"],"backgroundTag":"schema-validation-failed","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"}