{"record":{"id":"dfc038945848b5cd","repo":"dotnet/wpf","slug":"file-contains-data-in-format-version-0-but-the-software-can","errorCode":null,"errorMessage":"File contains data in format version {0}, but the software can only read that data in format version {1} or lower.","messagePattern":"File contains data in format version (.+?), but the software can only read that data in format version (.+?) or lower\\.","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/DataSpaceManager.cs","lineNumber":1638,"sourceCode":"                                        DataSpaceCurrentUpdaterVersion\n                                     );\n        }\n    }\n\n    /// <summary>\n    /// Verify that the current version of this class can read the DataSpace information in\n    /// this file.\n    /// </summary>\n    /// <exception cref=\"FileFormatException\">\n    /// If the current version of this class cannot read the DataSpace information in this file.\n    /// </exception>\n    private void ThrowIfIncorrectReaderVersion()\n    {\n        EnsureDataSpaceVersionInformation();\n\n        if (!_fileFormatVersion.IsReadableBy(DataSpaceCurrentReaderVersion))\n        {\n            throw new FileFormatException(\n                            SR.Format(\n                                SR.ReaderVersionError,\n                                _fileFormatVersion.ReaderVersion,\n                                DataSpaceCurrentReaderVersion\n                                )\n                            );\n        }\n    }\n\n    /// <summary>\n    /// Verify that the current version of this class can update the DataSpace information in\n    /// this file.\n    /// </summary>\n    /// <exception cref=\"FileFormatException\">\n    /// If the current version of this class cannot update the DataSpace information in this file,\n    /// or if the header information in the stream is corrupt.\n    /// </exception>\n    private void ThrowIfIncorrectUpdaterVersion()","sourceCodeStart":1620,"sourceCodeEnd":1656,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/DataSpaceManager.cs#L1620-L1656","documentation":"This FileFormatException is thrown by ThrowIfIncorrectReaderVersion when the data space information block's reader version is newer than DataSpaceCurrentReaderVersion supported by this build. The library can only read data-space metadata at or below its own supported format version, so files written by a newer implementation are rejected.","triggerScenarios":"Opening a package whose data space version block records a reader version greater than the current WPF data-space reader version; occurs during DataSpaceManager initialization via Package.Open.","commonSituations":"Packages produced by a newer runtime/version of the writing software being opened on an older .NET/WPF runtime, cross-platform transfers between framework versions, or tooling that bumps format versions.","solutions":["Open the package on a runtime whose data-space reader version is at least the file's recorded version (upgrade .NET/WPF).","Re-save the package with the current (older) runtime or a tool targeting the supported format version.","Check the package's data-space version info with a compound-file viewer to confirm the recorded reader version.","Catch FileFormatException with the version message and guide users to upgrade rather than retrying."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Check recorded reader version in the package metadata before opening (if pre-inspected):\nbool readable = recordedReaderVersion <= currentDataReaderVersion;","typeGuard":"bool IsReadableVersion(Version fileReaderVersion, Version supported) => fileReaderVersion.Major <= supported.Major && fileReaderVersion <= supported;","tryCatchPattern":"try { package = Package.Open(path); }\ncatch (FileFormatException ex) when (ex.Message.StartsWith(\"File contains data in format version\")) { Console.Error.WriteLine(\"Package needs a newer reader version; please upgrade the runtime.\"); throw; }","preventionTips":["Pin the writing and reading toolchains to compatible versions in your pipeline.","Downgrade/re-save packages to the supported format version before distribution.","Test package compatibility across every runtime version you deploy."],"tags":["file-format","version-mismatch","backward-compatibility"],"backgroundTag":"unsupported-operation","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"}