dotnet/wpf · error · FileFormatException

File contains data in format version

Error message

File contains data in format version {0}, but the software can only update that data in format version {1} or lower.

What it means

FileFormatException thrown by DataSpaceManager.ThrowIfIncorrectUpdaterVersion when the compound file's DataSpace format version block records an updater version newer than the version this library supports (currently 1.0). The library can read older data but refuses to open a file that would require upgrade logic it does not implement. This guards against silently corrupting files written by future versions of the format.

Solutions

  1. Open/write the file with the same or newer .NET runtime version that produced it
  2. Re-save the file with a tool/runtime whose DataSpace updater version is 1.0 or lower
  3. Inspect the DataSpace version info stream to confirm the updaterVersion recorded in the file
  4. If you own the writer code, do not bump the DataSpace updater version unless the reader is also updated

Example fix

// before
var pkg = Package.Open(path, FileMode.Open); // fails if updaterVersion > 1.0
// after
var pkg = Package.Open(path, FileMode.Open, FileAccess.Read); // same failure possible; instead ensure runtime matches writer, e.g. re-save:
// using (var newPkg = Package.Open(repairedPath, FileMode.Create)) { /* copy parts from a file written by a compatible runtime */ }
Defensive patterns

Strategy: try-catch

Validate before calling

// Caller-side: you cannot read the DataSpace version via public API before opening,
// but you can guard the open call and classify the failure.
try {
    using var pkg = Package.Open(path, FileMode.Open, FileAccess.Read);
} catch (FileFormatException ex) when (ex.Message.Contains("update")) {
    // file's DataSpace updater version > 1.0: use the runtime that wrote it
}

Try / catch

catch (FileFormatException ex) when (ex.InnerException == null && ex.Message.Contains("updater")) { /* fall back to writer runtime or re-save */ }

Prevention

When it happens

Trigger: Opening (Package.Open or direct CompoundFileContainer access) a compound file whose DataSpace version stream contains an updaterVersion greater than 1.0, i.e. written by a newer implementation that bumped the updater version.

Common situations: Files produced by newer .NET/WPF versions or third-party writers that advanced the DataSpace updater version; copying packages between machines with different framework versions; attempting to read a file saved by an upgraded tool with an older runtime.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/84f35adda17e3049. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/DataSpaceManager.cs:1662

                            );
        }
    }

    /// <summary>
    /// Verify that the current version of this class can update the DataSpace information in
    /// this file.
    /// </summary>
    /// <exception cref="FileFormatException">
    /// If the current version of this class cannot update the DataSpace information in this file,
    /// or if the header information in the stream is corrupt.
    /// </exception>
    private void ThrowIfIncorrectUpdaterVersion()
    {
        EnsureDataSpaceVersionInformation();

        if (!_fileFormatVersion.IsUpdatableBy(DataSpaceCurrentUpdaterVersion))
        {
            throw new FileFormatException(
                            SR.Format(
                                SR.UpdaterVersionError,
                                _fileFormatVersion.UpdaterVersion,
                                DataSpaceCurrentUpdaterVersion
                                )
                            );
        }
    }

    #endregion Version Methods
}

/// <summary>
/// Interface to be implemented by all data transform objects
/// </summary>
internal interface IDataTransform
{
    /// <summary>

View on GitHub (pinned to 81131a70a4)