dotnet/wpf · error · XmlException
SR.Format(SR.RequiredAttributeMissing…
Error message
SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.CreationTime, AnnotationXmlConstants.Elements.Annotation)
What it means
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.
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.
Example fix
// before <Annotation Id="..." TypeName="Highlight" LastModificationTime="..."> // after <Annotation Id="..." TypeName="Highlight" CreationTime="2026-09-14T10:00:00" LastModificationTime="...">
Defensive patterns
Strategy: validation
Validate before calling
bool HasCreationTime(XElement el) => DateTime.TryParse(el.Attribute("CreationTime")?.Value, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out _); Try / catch
try { annotationStore.Load(stream); } catch (XmlException ex) { log.Error("Missing CreationTime on annotation: " + ex.Message); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Hand-constructed annotation files, minified or sanitized XML, or copy/paste of annotation elements without all required attributes.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- SR.Format(SR.RequiredAttributeMissing…
- SR.Format(SR.RequiredAttributeMissing…
- SR.Format(SR.RequiredAttributeMissing…
- SR.Format(SR.UnexpectedAttribute, reader.LocalName…
- " }} " element found. Expected fixed page element ( }} ).
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/48b8e1473e9b61c5.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/Annotation.cs:676
throw new FormatException(SR.Format(SR.InvalidAttributeValue, AnnotationXmlConstants.Attributes.TypeName));
}
break;
default:
if (!Annotation.IsNamespaceDeclaration(reader))
throw new XmlException(SR.Format(SR.UnexpectedAttribute, reader.LocalName, AnnotationXmlConstants.Elements.Annotation));
break;
}
}
// Test to see if any required attribute was missing
if (_id.Equals(Guid.Empty))
{
throw new XmlException(SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.Id, AnnotationXmlConstants.Elements.Annotation));
}
if (_created.Equals(DateTime.MinValue))
{
throw new XmlException(SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.CreationTime, AnnotationXmlConstants.Elements.Annotation));
}
if (_modified.Equals(DateTime.MinValue))
{
throw new XmlException(SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.LastModificationTime, AnnotationXmlConstants.Elements.Annotation));
}
if (_typeName == null)
{
throw new XmlException(SR.Format(SR.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.TypeName, AnnotationXmlConstants.Elements.Annotation));
}
// Move back to the parent "Annotation" element
reader.MoveToContent();
}
private void OnCargoChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
FireResourceEvent((AnnotationResource)sender, AnnotationAction.Modified, CargoChanged);
}View on GitHub (pinned to 81131a70a4)