stride3d/stride · error · SerializationException

Invald ContentStorageHeader version.

Error message

Invald ContentStorageHeader version.

What it means

ContentStorageHeader.Read throws this when the version field in the header of an asset storage stream does not match any version the deserializer knows how to read. It guards against loading storage files written by incompatible (usually newer or corrupt) Stride versions. Note the message text contains a typo ('Invald') in some versions even though nameof is used elsewhere.

Solutions

  1. Regenerate or re-export the storage file with a Stride version compatible with the reading code.
  2. Update the Stride.Core.Serialization package/runtime to a version that supports the file's header version.
  3. Verify the file is not truncated or corrupted (compare file size/hash with the source).

Example fix

// before
var header = ContentStorageHeader.Read(stream); // throws on unknown version
// after
if (!ContentStorageHeader.TryRead(stream, out var header))
    throw new InvalidOperationException("Unsupported or corrupt storage header");
Defensive patterns

Strategy: validation

Validate before calling

// check magic/version before parsing
if (!stream.CanRead) throw new IOException("stream not readable");
var start = stream.Position;
if (!ContentStorageHeader.TryRead(stream, out var header))
    throw new InvalidOperationException("Unsupported storage header version");
stream.Position = start;

Try / catch

try { var h = ContentStorageHeader.Read(stream); }
catch (SerializationException ex) { /* unsupported version: regenerate file or upgrade runtime */ log.Error(ex); }

Prevention

When it happens

Trigger: Calling ContentStorageHeader.Read on a stream whose first bytes encode a version number outside the supported set of header versions.

Common situations: Opening a Stride package/asset storage file produced by a newer Stride editor; a truncated or corrupted storage file where garbage bytes are read as the version; mixing files between incompatible Stride releases.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/38091e91abee2765. Report an issue: GitHub.

Appendix: source

Thrown at sources/core/Stride.Core.Serialization/Streaming/ContentStorageHeader.cs:105

        var version = stream.ReadInt32();
        if (version == 1)
        {
            result.InitialImage = stream.ReadBoolean();
            result.DataUrl = stream.ReadString();
            result.PackageTime = new DateTime(stream.ReadInt64());
            int chunksCount = stream.ReadInt32();
            result.Chunks = new ChunkEntry[chunksCount];
            for (int i = 0; i < chunksCount; i++)
            {
                result.Chunks[i].Location = stream.ReadInt32();
                result.Chunks[i].Size = stream.ReadInt32();
            }
            result.HashCode = stream.ReadInt32();

            return;
        }

        throw new SerializationException($"Invald {nameof(ContentStorageHeader)} version.");
    }
}

View on GitHub (pinned to 96fad776d2)