{"record":{"id":"73600036cfc723a0","repo":"dotnet/wpf","slug":"sr-format-sr-requiredattributemissing-annotationxmlconstants-736000","errorCode":null,"errorMessage":"SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.LastModificationTime, AnnotationXmlConstants.Elements.Annotation)","messagePattern":"SR\\.Format\\(SR\\.RequiredAttributeMissing, AnnotationXmlConstants\\.Attributes\\.LastModificationTime, AnnotationXmlConstants\\.Elements\\.Annotation\\)","errorType":"exception","errorClass":"XmlException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/Annotation.cs","lineNumber":680,"sourceCode":"                    default:\n                        if (!Annotation.IsNamespaceDeclaration(reader))\n                           throw new XmlException(SR.Format(SR.UnexpectedAttribute, reader.LocalName, AnnotationXmlConstants.Elements.Annotation));\n                       break;\n                }\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;","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/Annotation.cs#L662-L698","documentation":"ReadAttributes requires the LastModificationTime attribute on every <Annotation> element. When _modified remains DateTime.MinValue after parsing, an XmlException is thrown because the annotations schema marks it mandatory.","triggerScenarios":"Deserializing annotation XML where the <Annotation> element is missing the LastModificationTime attribute or it was renamed.","commonSituations":"Manually edited annotation stores, XML stripped of 'optional-looking' attributes, or files exported from non-WPF annotation tooling.","solutions":["Add the LastModificationTime attribute with a valid dateTime value.","Regenerate the file from the WPF application that wrote it.","Verify exact attribute name 'LastModificationTime' (no 'LastModified' variants).","Run schema validation on the XML before load."],"exampleFix":"// before\n<Annotation Id=\"...\" TypeName=\"Highlight\" CreationTime=\"...\">\n// after\n<Annotation Id=\"...\" TypeName=\"Highlight\" CreationTime=\"...\" LastModificationTime=\"2026-09-14T10:00:00\">","handlingStrategy":"validation","validationCode":"bool HasLastModificationTime(XElement el) => DateTime.TryParse(el.Attribute(\"LastModificationTime\")?.Value, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out _);","typeGuard":null,"tryCatchPattern":"try { annotationStore.Load(stream); } catch (XmlException ex) { log.Error(\"Missing LastModificationTime: \" + ex.Message); }","preventionTips":["Write LastModificationTime whenever CreationTime is written.","Use AnnotationStore save/load rather than custom serialization.","Validate required attributes before load."],"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"}