Unity-Technologies/UnityCsReference · critical · InvalidDataException

Unsupported DependencyGraph version ({version}). DependencyG

Error message

Unsupported DependencyGraph version ({version}).
DependencyGraph file is either corrupted or from a newer version of Unity.

What it means

Thrown by AssemblyDependencyGraph.LoadFrom as InvalidDataException when the version byte read from the file does not match the current Version constant. The signature matched (so the file is a valid DependencyGraph file), but the format version is different, indicating it was written by a different Unity version. This is distinct from the signature error: the file is recognized but its internal layout is incompatible.

Source

Thrown at Editor/Mono/Scripting/APIUpdater/AssemblyDependencyGraph.cs:300

        {
            ValidateMinimumLength(stream);

            Span<byte> signatureHashSpan = stackalloc byte[Signature.Length];
            var read = stream.Read(signatureHashSpan);
            Debug.Assert(read == signatureHashSpan.Length); // ValidateMinimumLength() guarantees there's enough data to fulfill the request.

            if (!signatureHashSpan.SequenceEqual(Signature))
            {
                throw new InvalidDataException($"""
                                                Invalid signature ({BitConverter.ToString(signatureHashSpan.ToArray())}) found (Expected: {BitConverter.ToString(Signature)}).{Environment.NewLine}
                                                DependencyGraph file is either corrupted or from a previous version of Unity. If you observe inexplicable runtime/compilation errors, please delete `Library/` folder and reopen the project.
                                                """);
            }

            int version = stream.ReadByte();
            if (version != Version)
            {
                throw new InvalidDataException($"""
                                                Unsupported DependencyGraph version ({version}).{Environment.NewLine}
                                                DependencyGraph file is either corrupted or from a newer version of Unity.
                                                """);
            }

            Span<byte> hashLengthSpan = stackalloc byte[sizeof(long)];
            read = stream.Read(hashLengthSpan);
            if (read != hashLengthSpan.Length)
                throw new InvalidDataException($"Read only {read} out of {hashLengthSpan.Length} bytes for hash length.");

            long hashLengthSize = BitConverter.ToInt64(hashLengthSpan);
            Debug.Assert(hashLengthSize < 256);
            Span<byte> storedHash = stackalloc byte[(int)hashLengthSize];
            read = stream.Read(storedHash);
            if (read != hashLengthSize)
                throw new InvalidDataException($"Read only {read} out of {storedHash.Length} bytes for hash.");

            var startOfSerializedData = stream.Position;

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Delete the Library/ folder and reopen the project so Unity regenerates the DependencyGraph in the correct version.
  2. Standardize the Unity version across the team and CI.
  3. If upgrading, follow Unity's recommended upgrade path and clear cached data.

Example fix

// No code fix; environment issue.
// Terminal fix:
//   rm -rf Library/
// Then reopen the project in Unity.
Defensive patterns

Strategy: fallback

Validate before calling

// No runtime validation; version mismatch requires regenerating the file.
// Ensure consistent Unity editor version across all environments.

Try / catch

try
{
    AssemblyDependencyGraph.LoadFrom(stream);
}
catch (InvalidDataException)
{
    // Delete Library/ and reopen the project.
}

Prevention

When it happens

Trigger: Upgrading or downgrading Unity versions where the DependencyGraph format version changed. Opening a project last edited in a newer Unity version with an older editor.

Common situations: Team members on different Unity LTS versions. CI pipeline using a different Unity version than developers. Upgrading a project and not clearing Library/.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/f7174bf84e9946de. Report an issue: GitHub.