{"record":{"id":"6c8fe9df8f038cde","repo":"dotnet/wpf","slug":"reachpackaging-alreadyhasrootsequenceordocument","errorCode":null,"errorMessage":"ReachPackaging_AlreadyHasRootSequenceOrDocument","messagePattern":"ReachPackaging_AlreadyHasRootSequenceOrDocument","errorType":"exception","errorClass":"XpsPackagingException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs","lineNumber":544,"sourceCode":"        /// is already a starting part causes InvalidOperationException to be\n        /// thrown.\n        /// </summary>\n        /// <returns>Returns a IXpsFixedDocumentSequenceWriter instance.</returns>\n        /// <exception cref=\"SR.ReachPackaging_AlreadyHasRootSequenceOrDocument\">Package already has a root DocumentSequence.</exception>\n        public\n        IXpsFixedDocumentSequenceWriter\n        AddFixedDocumentSequence(\n            )\n        {\n            CheckDisposed();\n        \n            if( CurrentXpsManager == null )\n            {\n                throw new InvalidOperationException(SR.ReachPackaging_DocumentWasClosed);\n            }\n            if (_isInDocumentStage)\n            {\n                throw new XpsPackagingException(SR.ReachPackaging_AlreadyHasRootSequenceOrDocument);\n            }\n            if ( !CurrentXpsManager.Streaming && null != CurrentXpsManager.StartingPart)\n            {\n                throw new XpsPackagingException(SR.ReachPackaging_AlreadyHasRootSequenceOrDocument);\n            }\n\n            //\n            // Create the unique metro part in the package\n            //\n            PackagePart metroPart = CurrentXpsManager.GenerateUniquePart(XpsS0Markup.DocumentSequenceContentType);\n\n            //\n            // Create reader/writer and save a reference to it.\n            //\n            XpsFixedDocumentSequenceReaderWriter ds = new XpsFixedDocumentSequenceReaderWriter(CurrentXpsManager, this, metroPart);\n  \n            CurrentXpsManager.StartingPart = ((INode)ds).GetPart();\n","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs#L526-L562","documentation":"AddFixedDocumentSequence throws this InvalidOperationException when the package already contains a root FixedDocumentSequence (or fixed-document starting part). An XPS package may have only one document sequence root, so adding another is rejected. Check for an existing root sequence before calling.","triggerScenarios":"Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs:544 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call AddFixedDocumentSequence only once per package, before the root FixedDocumentSequence is written","Use the existing IXpsFixedDocumentSequenceWriter returned from the first call instead of adding another","Check whether the package already contains a root FixedDocumentSequence before calling"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}