stride3d/stride · error · InvalidOperationException

Object doesn't match, can't reload

Error message

Object doesn't match, can't reload

What it means

Reload consistency check in ContentManager.DeserializeObject: a Reload was requested on an existing object, but the object passed in is not the same instance currently referenced for that url/type. The manager refuses to overwrite a different live object during reload to avoid aliasing mismatches.

Solutions

  1. Pass the exact object previously returned by Load when calling Reload
  2. Unload first and then Load fresh instead of reloading a substitute instance
  3. Check for duplicate loads of the same url through different paths
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sources/core/Stride.Core.Serialization/Serialization/Contents/ContentManager.cs:314 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at sources/core/Stride.Core.Serialization/Serialization/Contents/ContentManager.cs:314

            ParentReference = parentReference;
            Url = url;
            ObjectType = objectType;
            Object = obj;
        }
    }

    private object DeserializeObject(string initialUrl, string newUrl, Type type, object? obj, ContentManagerLoaderSettings settings)
    {
        var serializeOperations = new Queue<DeserializeOperation>();
        serializeOperations.Enqueue(new DeserializeOperation(null, newUrl, type, obj));

        Reference? reference = null;
        if (obj != null)
        {
            reference = FindDeserializedObject(initialUrl, type);
            if (reference?.Object != obj)
            {
                throw new InvalidOperationException("Object doesn't match, can't reload");
            }
        }

        // Let's put aside old references, so that we unload them only afterwise (avoid a referenced object to be unloaded for no reason)
        HashSet<Reference> references = null!;
        if (reference != null)
        {
            // Let's collect dependent reference, and reset current list
            references = reference.References;
            reference.References = [];

            // Mark object as not deserialized yet
            reference.Deserialized = false;
        }

        bool isFirstOperation = true;
        object result = null;

View on GitHub (pinned to 96fad776d2)