{"record":{"id":"1e83f3abf4bf264c","repo":"dotnet/wpf","slug":"not-all-opened-dependents-were-committed","errorCode":null,"errorMessage":"Not all opened dependents were committed.","messagePattern":"Not all opened dependents were committed\\.","errorType":"exception","errorClass":"XpsPackagingException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsInterleavingPolicy.cs","lineNumber":527,"sourceCode":"\n        //\n        // When a flushing only the document,\n        // the document sequence  and the XpsDocument could still not\n        // be complete\n        //\n        private\n        void\n        ConfirmCommited()\n        {\n            foreach( InterleavingNode n in _interleavingNodes )\n            {\n                if(IsPartialFlushAllowed(n))\n                {\n                    continue;\n                }\n                if( !n.Commited )\n                {\n                    throw new XpsPackagingException(SR.ReachPackaging_DependantsNotCommitted);\n                }\n            }\n        }\n\n        /// <summary>\n        /// Tests wether a part can be flushed with out being committed\n        /// </summary>       \n        private\n        bool\n        IsPartialFlushAllowed( InterleavingNode n )\n        {\n            bool ret = false;\n            if(  n.Node is IXpsFixedDocumentWriter ||\n                 n.Node is IXpsFixedDocumentSequenceWriter ||\n                 n.Node is XpsDocument\n                )\n            {\n                ret = true;","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsInterleavingPolicy.cs#L509-L545","documentation":"XpsInterleavingPolicy.ConfirmCommited (called during Flush) throws XpsPackagingException(SR.ReachPackaging_DependantsNotCommitted) when an interleaved dependent part that does not allow partial flush has not been committed. The interleaving policy requires all opened dependents to be committed before the package can be flushed.","triggerScenarios":"Calling XpsDocument flush/close while a FixedPage/FixedDocument writer opened via the interleaving policy still has uncommitted parts (n.Commited == false and IsPartialFlushAllowed(n) is false).","commonSituations":"Forgetting to call Commit on a page writer before flushing the document; exception paths that abandon a writer mid-way; streaming XPS where interleaved parts must be committed in order.","solutions":["Call Commit() on every open IXpsFixedPageWriter/FixedDocumentWriter before flushing/closing the XpsDocument.","Ensure the document structure is completed in order (document → page → resources) so dependents get committed.","On error paths, dispose/close writers deterministically (using blocks) so partially built pages are committed or discarded properly."],"exampleFix":"// before\npageWriter.AddImage(\"image/png\");\ndocumentWriter.Commit(); // dependents not committed\n// after\npageWriter.AddImage(\"image/png\");\npageWriter.Commit();\ndocumentWriter.Commit();","handlingStrategy":"try-catch","validationCode":"bool allCommitted = openPages.All(p => p.IsCommitted);\nif (!allCommitted) throw new InvalidOperationException(\"Commit all page writers before flush\");","typeGuard":null,"tryCatchPattern":"try { xpsDocument.Flush(); }\ncatch (XpsPackagingException ex) when (ex.Message.Contains(\"not committed\")) { /* commit outstanding writers and retry */ }","preventionTips":["Always call Commit() on page/document writers inside using/finally blocks.","Follow the XPS write order: document sequence → document → pages → Commit all → flush."],"tags":["wpf","xps","interleaving","commit"],"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"}