{"record":{"id":"91b41d6a997dd927","repo":"dotnet/wpf","slug":"sr-reachserialization-noserializer-91b41d","errorCode":null,"errorMessage":"SR.ReachSerialization_NoSerializer","messagePattern":"SR\\.ReachSerialization_NoSerializer","errorType":"exception","errorClass":"XpsSerializationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCUIElementCollectionSerializerAsync.cs","lineNumber":212,"sourceCode":"        private \n        void \n        SerializeUIElement(\n            object uiElement\n            )\n        {\n            Visual visual = uiElement as Visual;\n\n            if(visual != null)\n            {\n                ReachSerializer serializer = SerializationManager.GetSerializer(visual);\n\n                if(serializer!=null)\n                {\n                    serializer.SerializeObject(visual);\n                }\n                else\n                {\n                    throw new XpsSerializationException(SR.ReachSerialization_NoSerializer);\n                }\n            }\n        }\n\n        #endregion Private Methods\n    };\n\n    internal class NgcUIElementCollectionSerializerContext :\n                   NGCSerializerContext\n    {\n        public\n        NgcUIElementCollectionSerializerContext(\n            NGCSerializerAsync          serializer,\n            SerializableObjectContext   objectContext,\n            IEnumerator                 enumerator,\n            SerializerAction            action\n            ):\n            base(serializer,objectContext,action)","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCUIElementCollectionSerializerAsync.cs#L194-L230","documentation":"XpsSerializationException thrown by NGCUIElementCollectionSerializerAsync.SerializeUIElement when the serialization manager cannot find any registered serializer capable of serializing the given Visual/UIElement. During XPS writing every element in the collection must have a matching serializer; if the lookup returns null the element type is unsupported.","triggerScenarios":"Iterating a UIElementCollection during XPS serialization and encountering an element type (custom Visual, third-party control, unsupported DrawingVisual variant) for which SerializerManager has no registered serializer.","commonSituations":"Exporting a WPF visual tree to XPS that contains custom or third-party controls not handled by the framework's serializer table; using elements introduced in newer framework versions with an older serialization path; printing visuals that bypass the standard document structure.","solutions":["Replace or wrap the unsupported element with a supported type (e.g. render the custom visual into a DrawingVisual/RenderTargetBitmap that the XPS writer accepts).","Check which element type has no serializer by inspecting the element passed to SerializeUIElement (visual.GetType()).","Ensure you use the standard document structure (FixedDocument/FixedPage) so elements are serialized through supported paths.","If a custom serializer exists, register it with the serialization manager before serialization begins."],"exampleFix":"// before\npanel.Children.Add(new MyCustomControl()); // no serializer registered\n// after\nvar bmp = RenderToBitmap(myCustomControl); // rasterize to a supported visual\npanel.Children.Add(new Image { Source = bmp });","handlingStrategy":"validation","validationCode":"foreach (var child in visualTree)\n    if (!IsFrameworkSupportedForXps(child.GetType()))\n        throw new NotSupportedException($\"No XPS serializer for {child.GetType()}\");","typeGuard":"static bool HasXpsSerializer(Visual v) =>\n    v is FixedPage || v is PageContent || v is DrawingVisual == false && v.GetType().Namespace.StartsWith(\"System.Windows\");","tryCatchPattern":"try { SerializeNextUIElement(element); }\ncatch (XpsSerializationException ex) when (ex.Message.Contains(\"NoSerializer\"))\n{ /* rasterize element to bitmap and continue */ }","preventionTips":["Avoid third-party/custom Visual subclasses in trees exported to XPS.","Pre-rasterize unsupported visuals to bitmaps before serialization.","Keep the export pipeline on standard FixedDocument/FixedPage structures.","Test printing/export with production visual trees early."],"tags":["wpf","xps","serialization","missing-serializer"],"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"}