dotnet/wpf · error · NotImplementedException
NotImplementedException(SR.MissingCaseXamlNodes)
Error message
NotImplementedException(SR.MissingCaseXamlNodes)
What it means
XamlWriter.WriteNode's switch over XamlNodeType has no handler for the node type it received, so it hits the default case and throws NotImplementedException. This is an internal exhaustiveness guard: the writer supports only the concrete XAML node kinds (Start/End Object, Start/End Member, Value, Namespace, None), and anything else is unsupported.
Solutions
- Ensure the source IXamlReader only emits standard XamlNodeType values; fix or replace the custom reader.
- Filter or transform unexpected nodes (e.g. via XamlNodeQueue/XamlNodeEnumerator) before calling WriteNode.
- Update System.Xaml/pipeline components so reader and writer node-type enums match.
- Add an explicit case/handling if you own a node type extension point.
Example fix
// before
while (reader.Read()) writer.WriteNode(reader); // NotImplementedException on unknown node
// after
while (reader.Read())
{
if (reader.NodeType == XamlNodeType.None) continue; // skip unsupported nodes
writer.WriteNode(reader);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (node is null || !Enum.IsDefined(typeof(XamlNodeType), node.NodeType))
throw new InvalidOperationException("Unsupported XAML node type in stream"); Type guard
bool IsWritableNode(IXamlReader r) => r.NodeType is XamlNodeType.StartObject or XamlNodeType.EndObject
or XamlNodeType.StartMember or XamlNodeType.EndMember or XamlNodeType.Value or XamlNodeType.Namespace or XamlNodeType.None; Try / catch
try { writer.WriteNode(reader); }
catch (NotImplementedException ex) { /* log node type; filter/skip node or fix custom reader */ } Prevention
- Only pipe nodes from well-behaved IXamlReader implementations.
- Filter the node stream (skip XamlNodeType.None and unknown kinds) before writing.
- Keep System.Xaml reader/writer versions aligned in mixed pipelines.
When it happens
Trigger: Feeding a XamlReader-produced node stream containing a node type WriteNode doesn't handle into XamlServices/xamlWriter.WriteNode; passing XamlNodeType.None-like or corrupted nodes from a custom IXamlReader implementation.
Common situations: Custom XAML readers/writers that emit non-standard node types; mixing nodes from different System.Xaml versions; piping a reader's GetReader results through a transform into XamlXmlWriter with an unexpected node in the stream.
Related errors
- ArgumentException: path
- ArgumentException: relativeTo
- ArgumentNullException: path
- ArgumentNullException: relativeTo
- NotImplementedException
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/350c63d4c23d33ac.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlWriter.cs:59
break;
case XamlNodeType.StartMember:
WriteStartMember(reader.Member);
break;
case XamlNodeType.EndMember:
WriteEndMember();
break;
case XamlNodeType.Value:
WriteValue(reader.Value);
break;
case XamlNodeType.None:
break;
default:
throw new NotImplementedException(SR.MissingCaseXamlNodes);
}
}
#region IDisposable
// See Framework Design Guidelines, pp. 254-256.
protected bool IsDisposed { get; private set; }
void IDisposable.Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
IsDisposed = true; // must call the base class to get IsDisposed == true;View on GitHub (pinned to 81131a70a4)