stride3d/stride · error · InvalidOperationException

The asset doesn't exist in the dependency manager anymore

Error message

The asset doesn't exist in the dependency manager anymore

What it means

After locating the asset item, AddAssetToComputePackage computes outgoing recursive dependencies via session.DependencyManager.ComputeDependencies. A null result means the dependency manager no longer tracks this asset's id, so compilation data cannot be built; an InvalidOperationException is thrown.

Solutions

  1. Ensure the session is fully loaded before building compile packages
  2. Rebuild/refresh the dependency manager (reload session) and retry
  3. Verify the asset still exists and its package is loaded

Example fix

// before
session.AddAssetToCompilePackage(item, cloned); // may throw after Clear()
// after
if (session.DependencyManager.FindDependencies(item.Id) != null)
    session.AddAssetToCompilePackage(item, cloned);
Defensive patterns

Strategy: validation

Validate before calling

var deps = session.DependencyManager.ComputeDependencies(item.Id, AssetDependencySearchOptions.Out);
if (deps == null) throw new InvalidOperationException("Dependency manager has no node for this asset; reload the session");

Try / catch

try { session.AddAssetToCompilePackage(item, cloned); }
catch (InvalidOperationException ex) when (ex.Message.Contains("dependency manager"))
{ logger.Error(ex, "Dependency graph stale; reload session"); }

Prevention

When it happens

Trigger: Calling AddAssetToCompilePackage when the asset id is absent from session.DependencyManager — e.g. the dependency manager was rebuilt/cleared, the asset was removed, or the session wasn't fully loaded.

Common situations: Calling during a partially loaded session, after session.Clear(), or after the asset's package was unloaded so dependency graph nodes were dropped.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at sources/assets/Stride.Core.Assets/PackageSession.Extensions.cs:41

        _ = new PackageSession(assetPackageCloned);

        AddAssetToCompilePackage(session, originalAssetItem, assetPackageCloned);

        return assetPackageCloned;
    }

    public static void AddAssetToCompilePackage(this PackageSession session, AssetItem originalAssetItem, Package assetPackageCloned)
    {
        ArgumentNullException.ThrowIfNull(originalAssetItem);

        // Find the asset from the session
        var assetItem = originalAssetItem.Package?.FindAsset(originalAssetItem.Id)
            ?? throw new ArgumentException("Cannot find the specified AssetItem instance in the session");

        // Calculate dependencies
        // Search only for references
        var dependencies = session.DependencyManager.ComputeDependencies(assetItem.Id, AssetDependencySearchOptions.Out | AssetDependencySearchOptions.Recursive, ContentLinkType.Reference)
            ?? throw new InvalidOperationException("The asset doesn't exist in the dependency manager anymore");
        var assetItemRootCloned = dependencies.Item.Clone();

        // Store the fullpath to the sourcefolder, this avoid us to clone hierarchy of packages
        assetItemRootCloned.SourceFolder = assetItem.FullPath.GetParent();

        if (assetPackageCloned.Assets.Find(assetItemRootCloned.Id) == null)
            assetPackageCloned.Assets.Add(assetItemRootCloned);

        // For each asset item dependency, clone it in the new package
        foreach (var assetLink in dependencies.LinksOut)
        {
            // Only add assets not already added (in case of circular dependencies)
            if (assetPackageCloned.Assets.Find(assetLink.Item.Id) == null)
            {
                // create a copy of the asset item and add it to the appropriate compile package
                var itemCloned = assetLink.Item.Clone();

                // Store the fullpath to the sourcefolder, this avoid us to clone hierarchy of packages

View on GitHub (pinned to 96fad776d2)