{"record":{"id":"a04e073be44c2355","repo":"dotnet/wpf","slug":"sr-reachserialization-noserializer-a04e07","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/ReachDocumentReferenceCollectionSerializerAsync.cs","lineNumber":169,"sourceCode":"        /// <summary>\n        ///     Called to serialize a single DocumentReference\n        /// </summary>\n        private \n        void\n        SerializeDocumentReference(\n            object documentReference\n            )\n        {\n            ReachSerializer serializer = SerializationManager.GetSerializer(documentReference);\n\n            if(serializer!=null)\n            {\n                serializer.SerializeObject(documentReference);\n            }\n            else\n            {\n                // should we throw if this is not a DocumentReference or just not do anything?\n                throw new XpsSerializationException(SR.ReachSerialization_NoSerializer);\n            }\n        }\n    };\n\n\n    internal class DocumentReferenceCollectionSerializerContext :\n                   ReachSerializerContext\n    {\n        public\n        DocumentReferenceCollectionSerializerContext(\n            ReachSerializerAsync        serializer,\n            SerializableObjectContext   objectContext,\n            IEnumerator                 enumerator,\n            SerializerAction            action\n            ):\n            base(serializer,objectContext,action)\n        {\n            this._enumerator = enumerator;","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentReferenceCollectionSerializerAsync.cs#L151-L187","documentation":"XpsSerializationException thrown by the async DocumentReferenceCollection serializer when it walks a collection and encounters an item for which no serializer can be produced. The serialization manager cannot find (or construct) a serializer for the object graph node, so the XPS package cannot be written and the operation aborts. The code comment ('should we throw if this is not a DocumentReference or just not do anything?') indicates the collection contained an object that is not a DocumentReference.","triggerScenarios":"Calling ReachDocumentReferenceCollectionSerializerAsync.SerializeDocumentReference (via SerializeNextDocumentReference) on a collection whose current item is not a DocumentReference, or an object type not registered with the serializer manager so serializer.SerializeObject resolves to null.","commonSituations":"Custom FixedDocumentSequence/DocumentReference graphs built manually; passing a FixedDocument into a DocumentReference collection by mistake; type missing from the serializer map after a .NET/WPF version change.","solutions":["Ensure every item in the serialized collection is a System.Windows.Documents.DocumentReference","Verify the object's type has a registered serializer with the XpsSerializationManager (use built-in types or register a custom serializer)","Catch XpsSerializationException around the save/WriteAsync call and log which collection item failed before rethrowing"],"exampleFix":"// before\nsequence.DocumentReferences.Add(fixedDocument); // wrong type\n// after\nDocumentReference dr = new DocumentReference { GetDocument = () => fixedDocument };\nsequence.DocumentReferences.Add(dr);","handlingStrategy":"validation","validationCode":"static bool IsSerializableCollection(System.Windows.Documents.DocumentReferenceCollection c) => c != null && c.Cast<object>().All(i => i is System.Windows.Documents.DocumentReference);","typeGuard":"static bool IsDocumentReference(object o) => o is System.Windows.Documents.DocumentReference;","tryCatchPattern":"try { writer.WriteAsync(sequence); } catch (System.Windows.Xps.XpsSerializationException ex) { log.Error(\"No serializer for collection item\", ex); throw; }","preventionTips":["Only add DocumentReference instances to DocumentReferences collections","Type-check collection items before a write","Keep a unit test that serializes the full document graph"],"tags":["xps","wpf","serialization","dotnet"],"backgroundTag":"missing-dependency","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"}