{"record":{"id":"48b8e1473e9b61c5","repo":"dotnet/wpf","slug":"sr-format-sr-requiredattributemissing-annotationxmlconstants-48b8e1","errorCode":null,"errorMessage":"SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.CreationTime, AnnotationXmlConstants.Elements.Annotation)","messagePattern":"SR\\.Format\\(SR\\.RequiredAttributeMissing, AnnotationXmlConstants\\.Attributes\\.CreationTime, AnnotationXmlConstants\\.Elements\\.Annotation\\)","errorType":"exception","errorClass":"XmlException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/Annotation.cs","lineNumber":676,"sourceCode":"                            throw new FormatException(SR.Format(SR.InvalidAttributeValue, AnnotationXmlConstants.Attributes.TypeName));\n                        }\n                        break;\n\n                    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        }","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/Annotation.cs#L658-L694","documentation":"XmlException from Annotation.ReadAttributes (reached via ReadXml when deserializing annotation XML): the required CreationTime attribute is absent from the Annotation element, so the annotation markup is malformed and cannot be deserialized.","triggerScenarios":"Loading annotation XML whose <Annotation> element lacks the CreationTime attribute, e.g. after stripping attributes or when the file was produced by tooling that omitted it.","commonSituations":"Hand-constructed annotation files, minified or sanitized XML, or copy/paste of annotation elements without all required attributes.","solutions":["Add the CreationTime attribute with a valid xsd:dateTime value (e.g. '2026-09-14T10:00:00').","Regenerate the annotation file from the creating application.","Check the attribute spelling is exactly 'CreationTime'.","Pre-validate required attributes before calling ReadXml."],"exampleFix":"// before\n<Annotation Id=\"...\" TypeName=\"Highlight\" LastModificationTime=\"...\">\n// after\n<Annotation Id=\"...\" TypeName=\"Highlight\" CreationTime=\"2026-09-14T10:00:00\" LastModificationTime=\"...\">","handlingStrategy":"validation","validationCode":"bool HasCreationTime(XElement el) => DateTime.TryParse(el.Attribute(\"CreationTime\")?.Value, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out _);","typeGuard":null,"tryCatchPattern":"try { annotationStore.Load(stream); } catch (XmlException ex) { log.Error(\"Missing CreationTime on annotation: \" + ex.Message); }","preventionTips":["Always emit CreationTime in xsd:dateTime round-trip format with invariant culture.","Do not strip 'optional-looking' attributes during XML preprocessing.","Schema-validate the annotation stream 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"}