stride3d/stride · error · InvalidOperationException

Couldn't find assembly 'Stride.Core' in restored packages

Error message

Couldn't find assembly 'Stride.Core' in restored packages

What it means

RegisterNativeDependencies loads Stride.Core.dll from the restored-package path map via Assembly.LoadFrom and immediately registers native libraries through reflection. If LoadFrom returns null (or the dictionary lookup finds no entry) the code throws this InvalidOperationException, meaning the Stride.Core assembly was not present in the restored package output.

Solutions

  1. Inspect the restored packages folder and confirm Stride.Core.dll exists at the mapped path.
  2. Re-run restore cleanly (delete obj/bin/package cache for the resolver) and retry SetupNuGet.
  3. Check that the requested package version actually contains Stride.Core in its lock file.
  4. If assembly loading fails due to missing dependencies, ensure all lock-file assemblies were deployed, not just some.

Example fix

// before: version that no longer ships Stride.Core
SetupNuGet(packageName: "Stride.Assets", version: "3.1.0", ...);
// after
SetupNuGet(packageName: "Stride.Assets", version: "4.2.1", ...); // lock file includes Stride.Core
Defensive patterns

Strategy: try-catch

Validate before calling

if (!File.Exists(expectedStrideCorePath))
    throw new InvalidOperationException($"Restored output missing Stride.Core.dll at {expectedStrideCorePath}; restore is incomplete.");

Try / catch

try
{
    resolver.SetupNuGet(packageName, packageVersion, targetFramework);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Couldn't find assembly 'Stride.Core'"))
{
    logger.Error("Stride.Core assembly absent from restore output; clean and re-restore with a matching package version.");
    throw;
}

Prevention

When it happens

Trigger: SetupNuGet succeeded but the assemblyNameToPath map lacks 'Stride.Core' or LoadFrom cannot load the DLL, returning null — e.g. restore produced no Stride.Core package, or the lock file listed different package ids.

Common situations: Restoring an older/newer Stride package set where Stride.Core was renamed or folded into another package; corrupted/partial restore output directory; filter in ListAssemblies excluding the assembly.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


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

Appendix: source

Thrown at sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs:270

                    // Remove entry from packageSources
                    settings.Remove("packageSources", packageSource);
                }
            }
        }
    }

    private static void CheckPackageSource(ISettings settings, string name, string url)
    {
        settings.AddOrUpdate("packageSources", new SourceItem(name, url));
    }

    /// <summary>
    /// Registers the listed native libs in Stride.Core.NativeLibraryHelper using reflection to avoid a compile time dependency on Stride.Core
    /// </summary>
    private static void RegisterNativeDependencies(Dictionary<string, string> assemblyNameToPath, List<string> nativeLibs)
    {
        var strideCoreAssembly = Assembly.LoadFrom(assemblyNameToPath["Stride.Core"])
            ?? throw new InvalidOperationException("Couldn't find assembly 'Stride.Core' in restored packages");
        var nativeLibraryHelperType = strideCoreAssembly.GetType("Stride.Core.NativeLibraryHelper")
            ?? throw new InvalidOperationException($"Couldn't find type 'Stride.Core.NativeLibraryHelper' in {strideCoreAssembly}");
        var registerDependencyMethod = nativeLibraryHelperType.GetMethod("RegisterDependency")
            ?? throw new InvalidOperationException($"Couldn't find method 'RegisterDependency' in {nativeLibraryHelperType}");
        foreach (var lib in nativeLibs)
            registerDependencyMethod.Invoke(null, [lib]);
    }

    /// <summary>
    /// Loads the listed native libs in Stride.Core.NativeLibraryHelper using reflection to avoid a compile time dependency on Stride.Core
    /// </summary>
    private static void LoadNativeDependencies(Dictionary<string, string> assemblyNameToPath, List<string> nativeLibs)
    {
        var strideCoreAssembly = Assembly.LoadFrom(assemblyNameToPath["Stride.Core"])
            ?? throw new InvalidOperationException("Couldn't find assembly 'Stride.Core' in restored packages");
        var nativeLibraryHelperType = strideCoreAssembly.GetType("Stride.Core.NativeLibraryHelper")
            ?? throw new InvalidOperationException($"Couldn't find type 'Stride.Core.NativeLibraryHelper' in {strideCoreAssembly}");
        var preloadLibraryMethod = nativeLibraryHelperType.GetMethod("PreloadLibrary")

View on GitHub (pinned to 96fad776d2)