{"record":{"id":"7022cd72078693f1","repo":"dotnet/wpf","slug":"serialization-of-this-type-of-object-is-not-supported","errorCode":null,"errorMessage":"Serialization of this type of object is not supported.","messagePattern":"Serialization of this type of object is not supported\\.","errorType":"exception","errorClass":"XpsSerializationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/XpsFontSerializationService.cs","lineNumber":58,"sourceCode":"            if(type == typeof(FixedDocumentSequence))\n            {\n                signal = FontSubsetterCommitPolicies.CommitEntireSequence;\n            }\n            else if(type ==  typeof(FixedDocument))\n            {\n                signal = FontSubsetterCommitPolicies.CommitPerDocument;\n            }\n            else if(type== typeof(FixedPage))\n            {\n                signal = FontSubsetterCommitPolicies.CommitPerPage;\n            }\n            else if(type == typeof(Visual))\n            {\n                signal = FontSubsetterCommitPolicies.CommitPerPage;\n            }\n            else\n            {\n                throw new XpsSerializationException(SR.ReachSerialization_NotSupported);\n            }\n            return _fontSubsetter.CommitFontSubsetsSignal(signal);\n        }\n        \n        /// <summary>\n        /// This method retieves a XpsFontSubsetter for\n        /// serializing a font to a Xps package. \n        /// This method assumes the font subsetter \n        /// has already been itialized.\n        /// </summary>\n        /// <returns>\n        /// A reference to a XpsFontSubsetter instance.\n        /// </returns>\n        public \n        XpsFontSubsetter\n        FontSubsetter\n        {\n            get","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/XpsFontSerializationService.cs#L40-L76","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nfontService.SignalCommit(page.GetType()); // may be a derived page type\n\n// after\nfontService.SignalCommit(typeof(FixedPage)); // exact type required by SignalCommit","handlingStrategy":"type-guard","validationCode":"static readonly Type[] CommitTypes =\n    { typeof(FixedDocumentSequence), typeof(FixedDocument), typeof(FixedPage), typeof(Visual) };\nbool ok = type != null && CommitTypes.Contains(type);\nif (!ok) throw new ArgumentException(\"SignalCommit requires an exact XPS content type.\");","typeGuard":"static bool IsCommittableType(Type type) =>\n    type == typeof(FixedDocumentSequence) || type == typeof(FixedDocument) ||\n    type == typeof(FixedPage) || type == typeof(Visual);","tryCatchPattern":"try\n{\n    fontService.SignalCommit(type);\n}\ncatch (XpsSerializationException ex) when (ex.Message.Contains(\"not supported\"))\n{\n    // fall back to per-page commit: _fontSubsetter.CommitFontSubsetsSignal(CommitPerPage)\n}","preventionTips":["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."],"tags":["wpf","xps","fonts","unsupported-type","serialization"],"backgroundTag":"unsupported-operation","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"}