dotnet/wpf · error · XpsSerializationException
Serialization of this type of object is not supported.
Error message
Serialization of this type of object is not supported.
What it means
XpsFontSerializationService.SignalCommit maps a document-structure type to a FontSubsetterCommitPolicies value; only FixedDocumentSequence, FixedDocument, FixedPage, and Visual are recognized. Any other Type (or null) falls into the else branch and throws XpsSerializationException with ReachSerialization_NotSupported. Callers invoke it when releasing font subsets at commit points (signalReleaseToFontService, ReleaseXmlWriter).
Solutions
- Pass exactly typeof(FixedDocumentSequence), typeof(FixedDocument), typeof(FixedPage), or typeof(Visual) — not derived types (the comparisons use ==).
- Null-check the type argument before calling SignalCommit.
- Catch XpsSerializationException and default to CommitPerPage for unknown types in custom pipelines.
Example fix
// before fontService.SignalCommit(page.GetType()); // may be a derived page type // after fontService.SignalCommit(typeof(FixedPage)); // exact type required by SignalCommit
Defensive patterns
Strategy: type-guard
Validate before calling
static readonly Type[] CommitTypes =
{ typeof(FixedDocumentSequence), typeof(FixedDocument), typeof(FixedPage), typeof(Visual) };
bool ok = type != null && CommitTypes.Contains(type);
if (!ok) throw new ArgumentException("SignalCommit requires an exact XPS content type."); Type guard
static bool IsCommittableType(Type type) =>
type == typeof(FixedDocumentSequence) || type == typeof(FixedDocument) ||
type == typeof(FixedPage) || type == typeof(Visual); Try / catch
try
{
fontService.SignalCommit(type);
}
catch (XpsSerializationException ex) when (ex.Message.Contains("not supported"))
{
// fall back to per-page commit: _fontSubsetter.CommitFontSubsetsSignal(CommitPerPage)
} Prevention
- Pass typeof(...) constants, never GetType() of possibly derived instances (checks use ==).
- Null-check the type before calling.
- Map derived page/document classes to their exact XPS base type first.
When it happens
Trigger: SignalCommit called with a type other than typeof(FixedDocumentSequence), typeof(FixedDocument), typeof(FixedPage), or typeof(Visual) — e.g. passing typeof(FixedPage) via a derived page type variable that is not exactly one of these (the check uses ==, not inheritance), or passing a null Type.
Common situations: Custom serialization loops calling SignalCommit with a content-element subtype (checks are exact reference equality against typeof, so subclasses fail); null type after a failed content lookup; extending the XPS model with custom container types.
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.
- No font service is registered with resource policy.
- Serialization of this type of object is not supported.
- Serialization of this type of object is not supported.
- SR.ReachSerialization_NoSerializer
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/7022cd72078693f1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/XpsFontSerializationService.cs:58
if(type == typeof(FixedDocumentSequence))
{
signal = FontSubsetterCommitPolicies.CommitEntireSequence;
}
else if(type == typeof(FixedDocument))
{
signal = FontSubsetterCommitPolicies.CommitPerDocument;
}
else if(type== typeof(FixedPage))
{
signal = FontSubsetterCommitPolicies.CommitPerPage;
}
else if(type == typeof(Visual))
{
signal = FontSubsetterCommitPolicies.CommitPerPage;
}
else
{
throw new XpsSerializationException(SR.ReachSerialization_NotSupported);
}
return _fontSubsetter.CommitFontSubsetsSignal(signal);
}
/// <summary>
/// This method retieves a XpsFontSubsetter for
/// serializing a font to a Xps package.
/// This method assumes the font subsetter
/// has already been itialized.
/// </summary>
/// <returns>
/// A reference to a XpsFontSubsetter instance.
/// </returns>
public
XpsFontSubsetter
FontSubsetter
{
getView on GitHub (pinned to 81131a70a4)