{"record":{"id":"f83f1882aacb727b","repo":"dotnet/wpf","slug":"sr-reachserialization-nofixeddocuments-f83f18","errorCode":null,"errorMessage":"SR.ReachSerialization_NoFixedDocuments","messagePattern":"SR\\.ReachSerialization_NoFixedDocuments","errorType":"exception","errorClass":"XpsSerializationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsSerializationManager.cs","lineNumber":924,"sourceCode":"        internal\n        void\n        RegisterDocumentSequenceStart()\n        {\n            _documentNumber = 0;\n        }\n\n\n        internal\n        void\n        RegisterDocumentSequenceEnd()\n        {\n            //\n            // It is invalid to have a document sequence with no fixed documents\n            // If no fixed documents have been searialzed throw\n            //\n            if( _pageNumber <= 0 )\n            {\n                throw new XpsSerializationException(SR.ReachSerialization_NoFixedDocuments);\n            }\n        }\n\n\n        internal\n        override\n        BasePackagingPolicy\n        PackagingPolicy\n        {\n            get\n            {\n                return _packagingPolicy;\n            }\n        }\n\n        internal\n        override\n        XpsResourcePolicy","sourceCodeStart":906,"sourceCodeEnd":942,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsSerializationManager.cs#L906-L942","documentation":"RegisterDocumentSequenceEnd validates that the FixedDocumentSequence being closed contained at least one FixedDocument. When no document was serialized (_pageNumber/document counter <= 0), it throws XpsSerializationException(SR.ReachSerialization_NoFixedDocuments), since an XPS package with an empty document sequence is invalid.","triggerScenarios":"Calling RegisterDocumentSequenceEnd (and the manager's end-of-serialization path) without any RegisterDocumentStart/RegisterDocumentEnd pair — e.g. a paginator returns zero documents, or all documents were skipped/aborted before the sequence is closed.","commonSituations":"Printing jobs with nothing to print (empty visual trees, filtered-out content); failure on the very first FixedDocument aborting serialization while cleanup still ends the sequence; batch print tools generating zero output.","solutions":["Ensure at least one FixedDocument is fully serialized before ending the document sequence.","Check the input for emptiness before starting serialization and surface a friendly 'nothing to print' error instead of producing an invalid package.","On early abort, discard the package/stream rather than calling the sequence-end registration.","Fix the paginator/serialization driver so its document count matches what is actually emitted."],"exampleFix":"// before\nmanager.RegisterDocumentSequenceStart();\n// no documents added\nmanager.RegisterDocumentSequenceEnd(); // throws\n// after\nmanager.RegisterDocumentSequenceStart();\nmanager.RegisterDocumentStart();\nmanager.RegisterPageStart();\n// ... content ...\nmanager.RegisterPageEnd();\nmanager.RegisterDocumentEnd();\nmanager.RegisterDocumentSequenceEnd();","handlingStrategy":"validation","validationCode":"if (documentsInSequence == 0)\n{\n    // nothing to serialize: abort the package instead of ending an empty sequence\n    AbortSerialization(\"No FixedDocuments were produced; nothing to print.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    manager.RegisterDocumentSequenceEnd();\n}\ncatch (System.Windows.Xps.XpsSerializationException ex) when (ex.Message.Contains(\"document\"))\n{\n    // empty sequence: discard the package and report 'nothing to print'\n    DiscardCurrentPackage();\n}","preventionTips":["Check that at least one FixedDocument was written before ending the sequence.","Validate input content (non-empty visual tree / paginator) before starting serialization.","On early failure, abandon the package entirely rather than closing it as a valid sequence."],"tags":["wpf","xps","state-machine","empty-document"],"backgroundTag":"invalid-state-transition","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"}