{"record":{"id":"e48be3db491142af","repo":"dotnet/wpf","slug":"sr-reachserialization-notsupported-e48be3","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/XpsOMSerializationManagerAsync.cs","lineNumber":48,"sourceCode":"            _batchOperationQueue = new Queue();\n        }\n\n        #endregion Constructor\n\n        #region packageSerializationManager override\n\n        public\n        override\n        void\n        SaveAsXaml(\n            Object serializedObject\n            )\n        {\n            ArgumentNullException.ThrowIfNull(serializedObject);\n\n            if (!XpsSerializationManager.IsSerializedObjectTypeSupported(serializedObject, IsBatchMode))\n            {\n                throw new XpsSerializationException(SR.ReachSerialization_NotSupported);\n            }\n\n            if (Simulator == null)\n            {\n                Simulator = new XpsOMHierarchySimulator(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":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMSerializationManagerAsync.cs#L30-L66","documentation":"XpsOMSerializationManagerAsync.SaveAsXaml checks the object type against XpsSerializationManager.IsSerializedObjectTypeSupported before serializing. Types that are not valid top-level serialization objects for the current batch mode (e.g. unsupported Visuals or document parts) cause XpsSerializationException(SR.ReachSerialization_NotSupported).","triggerScenarios":"Calling SaveAsXaml with a serializedObject whose type is not in the supported set for IsBatchMode — e.g. passing a plain UIElement/Visual or an out-of-order document part to the async XPS OM serializer.","commonSituations":"Passing arbitrary WPF visuals (buttons, panels) directly to SaveAsXaml instead of wrapping them in FixedPage/FixedDocument; batch-mode flag mismatch so an otherwise valid type is rejected; porting code from the sync XpsSerializationManager with different type rules.","solutions":["Serialize supported top-level objects only (FixedDocumentSequence, FixedDocument, FixedPage, and supported Visuals per IsSerializedObjectTypeResolved rules).","Wrap arbitrary content in a FixedPage/FixedDocument structure before calling SaveAsXaml.","Verify the IsBatchMode flag matches your usage; a type supported in single-document mode may be rejected in batch mode (or vice versa).","Pre-check with XpsSerializationManager.IsSerializedObjectTypeSupported(obj, isBatchMode) before calling SaveAsXaml."],"exampleFix":"// before\nmanagerAsync.SaveAsXaml(myButtonVisual); // throws\n// after\nif (XpsSerializationManager.IsSerializedObjectTypeSupported(myButtonVisual, managerAsync.IsBatchMode))\n{\n    managerAsync.SaveAsXaml(myButtonVisual);\n}\nelse\n{\n    var page = WrapInFixedPage(myButtonVisual);\n    managerAsync.SaveAsXaml(page);\n}","handlingStrategy":"validation","validationCode":"bool ok = XpsSerializationManager.IsSerializedObjectTypeSupported(obj, isBatchMode);\nif (!ok) throw new ArgumentException($\"{obj.GetType().Name} is not a supported SaveAsXaml target in batch mode {isBatchMode}.\");","typeGuard":"bool IsSupportedSaveTarget(object o, bool batch) => XpsSerializationManager.IsSerializedObjectTypeSupported(o, batch);","tryCatchPattern":"try { await managerAsync.SaveAsXamlAsync(obj); }\ncatch (XpsSerializationException ex) when (ex.Message.Contains(\"NotSupported\")) { /* wrap in FixedPage or use the correct serializer */ }","preventionTips":["Pre-check IsSerializedObjectTypeSupported before SaveAsXaml","Wrap raw visuals in FixedPage/FixedDocument","Keep the IsBatchMode flag consistent with your serialization sequence"],"tags":["wpf","xps","serialization","unsupported-type","async"],"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"}