{"record":{"id":"52fd246fba6efc5f","repo":"dotnet/wpf","slug":"cannot-find-the-appropriate-serializer-52fd24","errorCode":null,"errorMessage":"Cannot find the appropriate serializer.","messagePattern":"Cannot find the appropriate serializer\\.","errorType":"exception","errorClass":"XpsSerializationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCSerializationManager.cs","lineNumber":115,"sourceCode":"\n            if(reachSerializer != null)\n            {\n                //\n                // Call top-level type serializer, it will walk through the contents and\n                // all CLR and DP properties of the object and invoke the proper serializer\n                // and typeconverter respectively\n                //\n\n                reachSerializer.SerializeObject(serializedObject);\n\n                if(_isBatchMode)\n                {\n                    EndPage();\n                }\n            }\n            else\n            {\n                throw new XpsSerializationException(SR.ReachSerialization_NoSerializer);\n            }\n\n            Toolbox.EmitEvent(EventTrace.Event.WClientDRXSaveXpsEnd);\n        }\n\n\n        /// <summary>\n        ///\n        /// </summary>\n        public\n        void\n        Cancel(\n            )\n        {\n            if(_startDocCnt != 0 )\n            {\n                _device.AbortDocument();\n                _startDocCnt = 0;","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCSerializationManager.cs#L97-L133","documentation":"NgcSerializationManager.SaveAsXaml could not find a registered ReachSerializer capable of serializing the type of the object passed to it. The WPF XPS serialization pipeline keeps a table of supported types (FixedDocumentSequence, FixedDocument, FixedPage, etc.) and throws XpsSerializationException(SR.ReachSerialization_NoSerializer) when GetSerializer returns null for the supplied object.","triggerScenarios":"Calling SaveAsXaml on an NGC/NgcSerializationManager with an object whose type has no registered serializer — e.g. a raw Visual, Canvas, or any class that is not one of the supported Fixed* container types.","commonSituations":"Passing a UIElement or custom control to XpsDocument/XpsSerializationManager.SaveAsXaml expecting it to be converted to XPS; calling SaveAsXaml directly on a FixedPage instead of routing through the proper document hierarchy.","solutions":["Ensure the object passed to SaveAsXaml is a FixedDocumentSequence, FixedDocument, or FixedPage.","If saving arbitrary visuals, wrap them in a FixedPage (or use XpsDocument.ConvertToXps / XpsDocumentWriter with a VisualsToXpsDocument writer) instead of SaveAsXaml.","Verify you are using the correct serialization manager (NgcSerializationManager vs XpsSerializationManager) for the object type."],"exampleFix":"// before\nmanager.SaveAsXaml(myCanvas);\n// after\nFixedPage page = new FixedPage();\npage.Children.Add(myCanvas);\npage.Width = 816; page.Height = 1056;\nmanager.SaveAsXaml(page);","handlingStrategy":"type-guard","validationCode":"bool canSave = obj is FixedDocumentSequence || obj is FixedDocument || obj is FixedPage;\nif (!canSave) throw new NotSupportedException($\"No XPS serializer for {obj?.GetType().FullName}\");","typeGuard":"bool IsXpsSerializable(object o) => o is FixedDocumentSequence or FixedDocument or FixedPage;","tryCatchPattern":"try { manager.SaveAsXaml(obj); }\ncatch (XpsSerializationException ex) when (ex.Message.Contains(\"serializer\")) { /* log unsupported type, fall back to wrapping in FixedPage */ }","preventionTips":["Only pass Fixed* container types to SaveAsXaml","Wrap raw visuals in a FixedPage before saving","Check type support before starting the save operation"],"tags":["wpf","xps","serialization","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}