{"record":{"id":"f30c018227c97c9a","repo":"dotnet/wpf","slug":"sr-reachserialization-noserializer-f30c01","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/ReachDocumentReferenceCollectionSerializer.cs","lineNumber":93,"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","sourceCodeStart":75,"sourceCodeEnd":98,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentReferenceCollectionSerializer.cs#L75-L98","documentation":"SerializeDocumentReference throws this XpsSerializationException when the serializer manager cannot produce a serializer for an item inside the DocumentReference collection — i.e., an element retrieved from the enumerable is not a DocumentReference the serialization manager recognizes, so GetSerializerSuitableObject/serializer lookup fails. The code comments indicate the throw means the object is 'not a DocumentReference'.","triggerScenarios":"Iterating an IEnumerable<DocumentReference> whose element is null or of an unexpected type so the serializer lookup (SerializerManager.GetSerializerFor via the expression) yields no suitable serializer for the item.","commonSituations":"Custom collections typed as IEnumerable<DocumentReference> that actually contain nulls or derived/proxy objects the manager has no serializer for; mock or dynamic objects injected into the document reference collection during testing; broken serializer registration for DocumentReference.","solutions":["Verify every element in the collection is a non-null, concrete DocumentReference before serializing.","Ensure the standard DocumentReference serializer is registered with the SerializerManager (don't remove default ReachFramework serializer registrations).","Filter or repair the collection (skip/replace null or foreign items) before passing it to serialization."],"exampleFix":"// before: collection may contain foreign items\nserializer.SerializeObject(dirtyReferences);\n\n// after: sanitize first\nvar valid = dirtyReferences.Where(r => r is DocumentReference);\nserializer.SerializeObject(valid);","handlingStrategy":"validation","validationCode":"foreach (var r in references)\n    if (r is not DocumentReference) throw new ArgumentException(\"Collection contains non-DocumentReference items\");","typeGuard":"bool AllDocumentReferences(IEnumerable<object> items) => items.All(i => i is DocumentReference);","tryCatchPattern":"try { SerializeDocumentReferences(ctx); }\ncatch (XpsSerializationException ex) when (ex.Message.Contains(\"NoSerializer\")) {\n    // inspect collection element that has no serializer\n}","preventionTips":["Sanitize collections before serialization (remove nulls/foreign items)","Keep default ReachFramework serializer registrations intact","Use strongly typed List<DocumentReference> instead of loose enumerables"],"tags":["wpf","xps","serialization","missing-serializer"],"backgroundTag":"missing-dependency","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"}