{"record":{"id":"406c5948b3f0f0d1","repo":"dotnet/wpf","slug":"sr-dataspacemanagerdisposed","errorCode":null,"errorMessage":"SR.DataSpaceManagerDisposed","messagePattern":"SR\\.DataSpaceManagerDisposed","errorType":"exception","errorClass":"ObjectDisposedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/DataSpaceManager.cs","lineNumber":561,"sourceCode":"       }\n    }\n\n    // Check to see if the dispose method has been called.  If so, throw an\n    //  ObjectDisposedException.\n    internal void CheckDisposedStatus()\n    {\n        // First check root\n        _associatedStorage.CheckRootDisposedStatus();\n\n        // Check if we've been disposed\n        if( null == _dataSpaceMap )\n        {\n            Debug.Assert( null == _dataSpaceDefinitions,\n                \"Having a null data space map and a non-null data space definitions map is an inconsistent state\" );\n            Debug.Assert( null == _transformDefinitions,\n                \"Having a null data space map and a non-null transform definition map is an inconsistent state\" );\n\n            throw new ObjectDisposedException(null, SR.DataSpaceManagerDisposed);\n        }\n    }\n\n    /// <summary>\n    /// Define a data space with the given stack of transform objects and\n    /// labeled with the given name.  The transform stack is interpreted in\n    /// bottom-up order.  (Clear-text transform is last.)\n    /// </summary>\n    /// <param name=\"transformStack\">Transform stack</param>\n    /// <param name=\"newDataSpaceLabel\">New data space label</param>\n    internal void DefineDataSpace( string[] transformStack, string newDataSpaceLabel )\n    {\n        CheckDisposedStatus();\n        // Data space must have at least one transform\n        if( null == transformStack ||\n            0 == transformStack.Length )\n            throw new ArgumentException(\n                SR.TransformStackValid);","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/DataSpaceManager.cs#L543-L579","documentation":"DataSpaceManager throws ObjectDisposedException with message SR.DataSpaceManagerDisposed from its CheckDisposedStatus helper when any public/internal member is used after Dispose. This guards the compound-file data-space manager's internal dictionaries which are nulled on dispose.","triggerScenarios":"Calling DataSpaceManager methods (e.g. DefineDataSpace, GetDataSpace) after DataSpaceManager.Dispose(); Debug.Asserts confirm disposed state (null maps) before the throw.","commonSituations":"Using a CompoundFile DataSpaceManager after the parent compound file was closed or its using-block ended.","solutions":["Ensure the DataSpaceManager is created/reopened before use; do not use it after the owning CompoundFile is disposed.","Track disposal with a boolean/CanRead-style check if you cache the manager across operations.","Restructure code so all data-space work happens inside the compound file's open scope."],"exampleFix":"// before\nfile.Close();\nmanager.DefineDataSpace(stack, label); // throws\n// after\nusing (var file = CompoundFile.Open(path)) {\n    file.DataSpaceManager.DefineDataSpace(stack, label);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { manager.DefineDataSpace(stack, label); } catch (ObjectDisposedException) { manager = ReopenCompoundFile(path).DataSpaceManager; }","preventionTips":["Scope all DataSpaceManager usage inside the CompoundFile's open lifetime","Avoid storing the manager in long-lived fields"],"tags":["wpf","packaging","objectdisposed","compoundfile","dataspace"],"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"}