dotnet/wpf · error · XpsSerializationException
SR.ReachSerialization_NoSerializer
Error message
SR.ReachSerialization_NoSerializer
What it means
XpsSerializationException thrown by NGCUIElementCollectionSerializerAsync.SerializeUIElement when the serialization manager cannot find any registered serializer capable of serializing the given Visual/UIElement. During XPS writing every element in the collection must have a matching serializer; if the lookup returns null the element type is unsupported.
Solutions
- Replace or wrap the unsupported element with a supported type (e.g. render the custom visual into a DrawingVisual/RenderTargetBitmap that the XPS writer accepts).
- Check which element type has no serializer by inspecting the element passed to SerializeUIElement (visual.GetType()).
- Ensure you use the standard document structure (FixedDocument/FixedPage) so elements are serialized through supported paths.
- If a custom serializer exists, register it with the serialization manager before serialization begins.
Example fix
// before
panel.Children.Add(new MyCustomControl()); // no serializer registered
// after
var bmp = RenderToBitmap(myCustomControl); // rasterize to a supported visual
panel.Children.Add(new Image { Source = bmp }); Defensive patterns
Strategy: validation
Validate before calling
foreach (var child in visualTree)
if (!IsFrameworkSupportedForXps(child.GetType()))
throw new NotSupportedException($"No XPS serializer for {child.GetType()}"); Type guard
static bool HasXpsSerializer(Visual v) =>
v is FixedPage || v is PageContent || v is DrawingVisual == false && v.GetType().Namespace.StartsWith("System.Windows"); Try / catch
try { SerializeNextUIElement(element); }
catch (XpsSerializationException ex) when (ex.Message.Contains("NoSerializer"))
{ /* rasterize element to bitmap and continue */ } Prevention
- Avoid third-party/custom Visual subclasses in trees exported to XPS.
- Pre-rasterize unsupported visuals to bitmaps before serialization.
- Keep the export pipeline on standard FixedDocument/FixedPage structures.
- Test printing/export with production visual trees early.
When it happens
Trigger: Iterating a UIElementCollection during XPS serialization and encountering an element type (custom Visual, third-party control, unsupported DrawingVisual variant) for which SerializerManager has no registered serializer.
Common situations: Exporting a WPF visual tree to XPS that contains custom or third-party controls not handled by the framework's serializer table; using elements introduced in newer framework versions with an older serialization path; printing visuals that bypass the standard document structure.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot find the appropriate serializer.
- Cannot find the appropriate serializer.
- SR.ReachSerialization_NoSerializer
- SR.ReachSerialization_NoSerializer
- SR.ReachSerialization_NoSerializer
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/91b41d6a997dd927.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCUIElementCollectionSerializerAsync.cs:212
private
void
SerializeUIElement(
object uiElement
)
{
Visual visual = uiElement as Visual;
if(visual != null)
{
ReachSerializer serializer = SerializationManager.GetSerializer(visual);
if(serializer!=null)
{
serializer.SerializeObject(visual);
}
else
{
throw new XpsSerializationException(SR.ReachSerialization_NoSerializer);
}
}
}
#endregion Private Methods
};
internal class NgcUIElementCollectionSerializerContext :
NGCSerializerContext
{
public
NgcUIElementCollectionSerializerContext(
NGCSerializerAsync serializer,
SerializableObjectContext objectContext,
IEnumerator enumerator,
SerializerAction action
):
base(serializer,objectContext,action)View on GitHub (pinned to 81131a70a4)