{"record":{"id":"8d2f8d15d83ec102","repo":"dotnet/wpf","slug":"sr-reachserialization-notsupported-8d2f8d","errorCode":null,"errorMessage":"SR.ReachSerialization_NotSupported","messagePattern":"SR\\.ReachSerialization_NotSupported","errorType":"exception","errorClass":"XpsSerializationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsSerializationManagerAsync.cs","lineNumber":69,"sourceCode":"\n\n        /// <summary>\n        ///\n        /// </summary>\n        /// <exception cref=\"ArgumentNullException\">serializedObject is NULL.</exception>\n        /// <exception cref=\"XpsSerializationException\">serializedObject is not a supported type.</exception>\n        public\n        override\n        void\n        SaveAsXaml(\n            Object  serializedObject\n            )\n        {\n            ArgumentNullException.ThrowIfNull(serializedObject);\n\n            if (!IsSerializedObjectTypeSupported(serializedObject))\n            {\n                throw new XpsSerializationException(SR.ReachSerialization_NotSupported);\n            }\n\n            if(Simulator == null)\n            {\n                Simulator = new ReachHierarchySimulator(this,\n                                                         serializedObject);\n            }\n\n            if(!IsSimulating)\n            {\n                Simulator.BeginConfirmToXPSStructure(IsBatchMode);\n                IsSimulating = true;\n            }\n\n            if(IsBatchMode)\n            {\n                //\n                // Add the Visual received in to the queue","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsSerializationManagerAsync.cs#L51-L87","documentation":"XpsSerializationManagerAsync.SaveAsXaml validates that the object type being serialized is supported before starting async XPS serialization. If the object's type is not in the supported set, it throws XpsSerializationException with SR.ReachSerialization_NotSupported. The library only knows how to serialize a fixed set of types (Visuals, FixedDocument/Sequence, containers, etc.).","triggerScenarios":"Calling SaveAsXaml with a serializedObject whose type fails IsSerializedObjectTypeSupported (after passing the null check) — e.g. passing an arbitrary business object or unsupported DependencyObject.","commonSituations":"Developers try to SaveAsXaml a custom control, a Window, or a plain data object instead of a Visual/FixedDocument/FixedPage, expecting generic object serialization.","solutions":["Pass a supported serializable type (Visual, FixedPage, FixedDocument, FixedDocumentSequence) to SaveAsXaml.","Wrap unsupported content in a container that IS serializable, e.g. place the element in a FixedPage or use a VisualsCollator.","Pre-check the object type against supported types before calling SaveAsXaml."],"exampleFix":"// before\nmanager.SaveAsXaml(myCustomBusinessObject);\n// after\nFixedPage page = LayoutAsFixedPage(myVisual);\nmanager.SaveAsXaml(page);","handlingStrategy":"validation","validationCode":"bool IsSupported(object o) => o is Visual || o is FixedDocument || o is FixedDocumentSequence || o is FixedPage;\nif (!IsSupported(obj)) throw new ArgumentException(\"Type not serializable to XPS\", nameof(obj));","typeGuard":"bool IsXpsSerializable(object o) => o is Visual || o is FixedDocument || o is FixedDocumentSequence;","tryCatchPattern":null,"preventionTips":["Only pass Visual/FixedDocument/FixedDocumentSequence/FixedPage objects to SaveAsXaml.","Wrap arbitrary UI content in a FixedPage or use XpsDocumentWriter.Write(Visual).","Add a pre-serialization type assert in dev builds."],"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-21T21:30:21.729Z"}