stride3d/stride · error · InvalidOperationException

path [ ] cannot be resolved to a provider.

Error message

path [{path}] cannot be resolved to a provider.

What it means

ResolveProvider walks registered virtual file providers to find one whose RootPath matches (or is the longest prefix of) the given path. If ResolveProviderUnsafe yields no provider, this InvalidOperationException is thrown because the path cannot be mapped to any mounted provider.

Solutions

  1. Verify the provider for the path's root is registered (VirtualFileSystem.GetProvider) before calling.
  2. Ensure initialization code (RegisterProvider calls) has run before any file operations.
  3. Check the path prefix/spelling against the registered providers' RootPath values.
  4. Use ResolveProviderUnsafe if you need to handle the missing-provider case without an exception.

Example fix

// before
var resolved = VirtualFileSystem.ResolveProvider(path, true); // throws
// after
var unsafeResult = VirtualFileSystem.ResolveProviderUnsafe(path, true);
if (unsafeResult.Provider == null)
    throw new InvalidOperationException($"No provider mounted for {path}; check RegisterProvider calls.");
var resolved = VirtualFileSystem.ResolveProvider(path, true);
Defensive patterns

Strategy: validation

Validate before calling

var probe = VirtualFileSystem.ResolveProviderUnsafe(path, true);
if (probe.Provider == null)
    throw new InvalidOperationException($"No provider mounted for '{path}'. Register providers first.");

Try / catch

try { var r = VirtualFileSystem.ResolveProvider(path, true); }
catch (InvalidOperationException ex) { logger.LogWarning(ex, "Unresolved VFS path {Path}", path); return null; }

Prevention

When it happens

Trigger: Calling ResolveProvider (directly or via file APIs like result/sourceResult/destinationResult helpers) with a path whose root does not match any registered provider, e.g. "/missing/files/a.bin" when no provider is mounted at "/missing" or the root "/" provider is absent; or before RegisterProvider ran for that mount.

Common situations: Typos in mount root names; accessing virtual files before engine/service initialization registered providers; paths with wrong casing or missing leading '/'; tests that never set up the asset provider.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at sources/core/Stride.Core.IO/VirtualFileSystem.cs:510

                result.Append(DirectorySeparatorChar);
        }

        return result.ToString();
    }

    /// <summary>
    /// Resolves the virtual file provider for a given path.
    /// </summary>
    /// <param name="path">The path.</param>
    /// <param name="resolveTop">if set to <c>true</c> [resolve top].</param>
    /// <returns>The virtual file system provider and local path in it.</returns>
    /// <exception cref="InvalidOperationException">path cannot be resolved to a provider.</exception>
    public static ResolveProviderResult ResolveProvider(string path, bool resolveTop)
    {
        ArgumentNullException.ThrowIfNull(path);
        var result = ResolveProviderUnsafe(path, resolveTop);
        if (result.Provider == null)
            throw new InvalidOperationException($"path [{path}] cannot be resolved to a provider.");
        return result;
    }

    private static int LastIndexOfDirectorySeparator(string path)
    {
        int length = path.Length;
        while (--length >= 0)
        {
            var c = path[length];
            if (c == DirectorySeparatorChar || c == AltDirectorySeparatorChar)
            {
                return length;
            }
        }
        return -1;
    }

    public static ResolveProviderResult ResolveProviderUnsafe(string path, bool resolveTop)

View on GitHub (pinned to 96fad776d2)