{"record":{"id":"039c683842c297a2","repo":"dotnet/wpf","slug":"sr-reachserialization-noserializer-039c68","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/ReachDocumentReferenceSerializerAsync.cs","lineNumber":127,"sourceCode":"                // Give a parser item a kick\n                document.Dispatcher.Invoke(DispatcherPriority.ApplicationIdle,\n                    new DispatcherOperationCallback(Idle), null);\n            }\n\n            if (document != null)\n            {\n                ReachSerializer serializer = SerializationManager.GetSerializer(document);\n\n                if(serializer!=null)\n                {\n                    serializer.SerializeObject(document);\n                }\n                else\n                {\n                    //\n                    // This shouldn't ever happen.\n                    //\n                    throw new XpsSerializationException(SR.ReachSerialization_NoSerializer);\n                }\n            }\n\n        }\n    };\n}\n","sourceCodeStart":109,"sourceCodeEnd":134,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentReferenceSerializerAsync.cs#L109-L134","documentation":"Async counterpart of the same invariant: ReachDocumentReferenceSerializerAsync.SerializeDocument (driven by AsyncOperation) throws XpsSerializationException when the resolved FixedDocument has no available serializer. Because this runs on the async serialization operation, the exception surfaces through the async write path and aborts the whole XPS package write.","triggerScenarios":"Async XPS save (e.g. XpsDocument.CreateXpsDocumentWriter + WriteAsync) reaching a document whose concrete type has no serializer registered in the manager.","commonSituations":"WriteAsync on a FixedDocumentSequence with custom document types; mid-migration code where the async path was missed when adding a custom serializer to the sync path only.","solutions":["Use standard FixedDocument types or register the custom serializer for the async manager too","Confirm the same graph serializes synchronously, then diff the serializer registrations","Catch XpsSerializationException from the async operation and identify the document type before retrying"],"exampleFix":"// before\nmanager.RegisterSerializer(customDocType, null);\n// after\nmanager.RegisterSerializer(customDocType, new CustomFixedDocumentSerializer());","handlingStrategy":"try-catch","validationCode":"bool ok = dr.GetDocument?.Invoke() is System.Windows.Documents.FixedDocument;","typeGuard":"static bool IsFixedDocument(object o) => o is System.Windows.Documents.FixedDocument;","tryCatchPattern":"try { writer.WriteAsync(sequence); } catch (System.Windows.Xps.XpsSerializationException ex) { log.Error(\"Async serializer missing for document\", ex); throw; }","preventionTips":["Mirror sync and async serializer registrations","Prefer built-in FixedDocument types on the async path","Exercise WriteAsync in CI with the real document graph"],"tags":["xps","wpf","serialization","async","dotnet"],"backgroundTag":"internal-invariant-violation","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"}