stride3d/stride · error · InvalidOperationException

Content not loaded through this ContentManager.

Error message

Content not loaded through this ContentManager.

What it means

Ownership guard in ContentManager.Unload: the object being unloaded is not present in this ContentManager's LoadedAssetReferences table, i.e. it was never loaded through this instance (or was loaded by a different ContentManager). Each manager only tracks its own loads.

Solutions

  1. Unload the object with the same ContentManager instance that loaded it
  2. Check IsLoaded/LoadedAssetReferences before calling Unload
  3. If multiple managers are in play, route unload calls to the owning manager
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sources/core/Stride.Core.Serialization/Serialization/Contents/ContentManager.cs:242 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/8e8bb7f9833f5527. Report an issue: GitHub.

Appendix: source

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

                return false;
            }

            url = reference.Url;
            return true;
        }
    }

    /// <summary>
    /// Unloads the specified asset.
    /// </summary>
    /// <param name="obj">The object to unload.</param>
    /// <exception cref="InvalidOperationException">Content not loaded through this ContentManager.</exception>
    public void Unload(object obj)
    {
        lock (LoadedAssetUrls)
        {
            if (!LoadedAssetReferences.TryGetValue(obj, out var reference))
                throw new InvalidOperationException("Content not loaded through this ContentManager.");

            // Release reference
            DecrementReference(reference, true);
        }
    }

    /// <summary>
    /// Unloads the asset at the specified URL.
    /// </summary>
    /// <param name="url">The URL.</param>
    /// <exception cref="System.InvalidOperationException">Content not loaded through this ContentManager.</exception>
    public void Unload(string url)
    {
        lock (LoadedAssetUrls)
        {
            // Try to find already loaded object
            if (!LoadedAssetUrls.TryGetValue(ResolveUrl(url), out var reference))
                throw new InvalidOperationException("Content not loaded through this ContentManager.");

View on GitHub (pinned to 96fad776d2)