{"record":{"id":"cdcca03e5d8a318e","repo":"dotnet/wpf","slug":"sr-format-sr-requiredattributemissing-annotationxmlconstants-cdcca0","errorCode":null,"errorMessage":"SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.TypeName, AnnotationXmlConstants.Elements.Annotation)","messagePattern":"SR\\.Format\\(SR\\.RequiredAttributeMissing, AnnotationXmlConstants\\.Attributes\\.TypeName, AnnotationXmlConstants\\.Elements\\.Annotation\\)","errorType":"exception","errorClass":"XmlException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/Annotation.cs","lineNumber":684,"sourceCode":"                }\n            }\n\n            // Test to see if any required attribute was missing\n            if (_id.Equals(Guid.Empty))\n            {\n                throw new XmlException(SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.Id, AnnotationXmlConstants.Elements.Annotation));\n            }\n            if (_created.Equals(DateTime.MinValue))\n            {\n                throw new XmlException(SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.CreationTime, AnnotationXmlConstants.Elements.Annotation));\n            }\n            if (_modified.Equals(DateTime.MinValue))\n            {\n                throw new XmlException(SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.LastModificationTime, AnnotationXmlConstants.Elements.Annotation));\n            }\n            if (_typeName == null)\n            {\n                throw new XmlException(SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.TypeName, AnnotationXmlConstants.Elements.Annotation));\n            }\n\n            // Move back to the parent \"Annotation\" element\n            reader.MoveToContent();\n        }\n\n        private void OnCargoChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)\n        {\n            FireResourceEvent((AnnotationResource)sender, AnnotationAction.Modified, CargoChanged);\n        }\n\n        private void OnCargosChanged(object sender, NotifyCollectionChangedEventArgs e)\n        {\n            AnnotationAction action = AnnotationAction.Added;\n            IList changedItems = null;\n\n            switch (e.Action)\n            {","sourceCodeStart":666,"sourceCodeEnd":702,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/Annotation.cs#L666-L702","documentation":"ReadAttributes requires the TypeName attribute identifying the annotation type (e.g. Highlight, TextStickyNote). If _typeName is still null after attribute parsing, an XmlException is thrown because the type drives how the annotation is instantiated.","triggerScenarios":"Loading annotation XML whose <Annotation> element lacks the TypeName attribute, or where TypeName was misspelled so it was rejected earlier as an unexpected attribute.","commonSituations":"Custom annotation producers that omit TypeName, hand-written XML, or attribute renamed by a transformation step.","solutions":["Add TypeName with a valid annotation type value (e.g. 'Highlight', 'TextStickyNote', 'InkStickyNote').","Ensure the spelling matches AnnotationXmlConstants.Attributes.TypeName so it is recognized rather than rejected as unexpected.","Regenerate the annotation stream via AnnotationStore/AnnotationService.","Validate required attributes (Id, TypeName, CreationTime, LastModificationTime) before load."],"exampleFix":"// before\n<Annotation Id=\"...\" CreationTime=\"...\" LastModificationTime=\"...\">\n// after\n<Annotation Id=\"...\" TypeName=\"Highlight\" CreationTime=\"...\" LastModificationTime=\"...\">","handlingStrategy":"validation","validationCode":"bool HasTypeName(XElement el) => !string.IsNullOrEmpty(el.Attribute(\"TypeName\")?.Value) && new[]{\"Highlight\",\"TextStickyNote\",\"InkStickyNote\"}.Contains(el.Attribute(\"TypeName\").Value);","typeGuard":null,"tryCatchPattern":"try { annotationStore.Load(stream); } catch (XmlException ex) { log.Error(\"Missing annotation TypeName: \" + ex.Message); }","preventionTips":["Always include a known TypeName value when producing annotation XML.","Check for misspelled attribute names that end up rejected as unexpected before the missing-attribute error fires.","Use AnnotationService/AnnotationStore to author annotation XML."],"tags":["xml","wpf","deserialization"],"backgroundTag":"missing-required-argument","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"}