stride3d/stride · error · ArgumentException

Invalid assembly path. Doesn't contain directory information

Error message

Invalid assembly path. Doesn't contain directory information

What it means

AssemblyContainer.LoadAssemblyFromPath resolves the given path to a full path and extracts its directory; if GetDirectoryName returns null (e.g. root-only path) or the directory does not exist on disk, it cannot set up assembly probing, so it throws an ArgumentException.

Solutions

  1. Verify the directory exists before calling: Directory.Exists(Path.GetDirectoryName(Path.GetFullPath(path))).
  2. Pass an absolute path whose directory exists (e.g. Path.Combine(AppContext.BaseDirectory, "plugins", "MyPlugin.dll")).
  3. Fix the configured path or deploy the missing assembly directory.
  4. Catch ArgumentException and surface a clear configuration error to the user.

Example fix

// before
container.LoadAssemblyFromPath("MyPlugin.dll"); // dir may not exist
// after
var path = Path.Combine(AppContext.BaseDirectory, "plugins", "MyPlugin.dll");
if (!Directory.Exists(Path.GetDirectoryName(path))) throw new DirectoryNotFoundException(path);
container.LoadAssemblyFromPath(path);
Defensive patterns

Strategy: validation

Validate before calling

var full = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, path));
var dir = Path.GetDirectoryName(full);
if (string.IsNullOrEmpty(dir) || !Directory.Exists(dir)) throw new DirectoryNotFoundException($"Assembly directory does not exist: {dir}");
container.LoadAssemblyFromPath(full);

Type guard

bool IsValidAssemblyPath(string? p) { if (string.IsNullOrWhiteSpace(p)) return false; var d = Path.GetDirectoryName(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, p))); return d != null && Directory.Exists(d); }

Try / catch

try { asm = container.LoadAssemblyFromPath(path); }
catch (ArgumentException ex) when (ex.Message.Contains("Invalid assembly path")) { /* report bad configured path, fall back to default plugin dir */ }

Prevention

When it happens

Trigger: Calling LoadAssemblyFromPath with a relative filename whose directory doesn't exist under Environment.CurrentDirectory, a path to a file in a deleted/renamed folder, or a bare root path with no directory component.

Common situations: Hard-coded or config-supplied plugin paths that don't exist on the target machine; copying the app without its plugin directories; case/drive-letter differences between environments; current working directory different from what relative paths assume.

Related errors


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

Appendix: source

Thrown at sources/core/Stride.Core.Design/Reflection/AssemblyContainer.cs:88

        }
    }

    public Assembly? LoadAssemblyFromPath(string assemblyFullPath, ILogger? outputLog = null)
    {
#if NET6_0_OR_GREATER
        ArgumentNullException.ThrowIfNull(assemblyFullPath);
#else
        if (assemblyFullPath is null) throw new ArgumentNullException(nameof(assemblyFullPath));
#endif

        log = new LoggerResult();

        assemblyFullPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, assemblyFullPath));
        var assemblyDirectory = Path.GetDirectoryName(assemblyFullPath);

        if (assemblyDirectory == null || !Directory.Exists(assemblyDirectory))
        {
            throw new ArgumentException("Invalid assembly path. Doesn't contain directory information");
        }

        try
        {
            return LoadAssemblyFromPathInternal(assemblyFullPath);
        }
        finally
        {
            if (outputLog != null)
            {
                log.CopyTo(outputLog);
            }
        }
    }

    public bool UnloadAssembly(Assembly assembly)
    {
        lock (loadedAssemblies)

View on GitHub (pinned to 96fad776d2)