{"record":{"id":"08929ec1df24831b","repo":"stride3d/stride","slug":"couldn-t-find-assembly-stride-core-in-restored-packages","errorCode":null,"errorMessage":"Couldn't find assembly 'Stride.Core' in restored packages","messagePattern":"Couldn't find assembly 'Stride\\.Core' in restored packages","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs","lineNumber":270,"sourceCode":"                    // Remove entry from packageSources\n                    settings.Remove(\"packageSources\", packageSource);\n                }\n            }\n        }\n    }\n\n    private static void CheckPackageSource(ISettings settings, string name, string url)\n    {\n        settings.AddOrUpdate(\"packageSources\", new SourceItem(name, url));\n    }\n\n    /// <summary>\n    /// Registers the listed native libs in Stride.Core.NativeLibraryHelper using reflection to avoid a compile time dependency on Stride.Core\n    /// </summary>\n    private static void RegisterNativeDependencies(Dictionary<string, string> assemblyNameToPath, List<string> nativeLibs)\n    {\n        var strideCoreAssembly = Assembly.LoadFrom(assemblyNameToPath[\"Stride.Core\"])\n            ?? throw new InvalidOperationException(\"Couldn't find assembly 'Stride.Core' in restored packages\");\n        var nativeLibraryHelperType = strideCoreAssembly.GetType(\"Stride.Core.NativeLibraryHelper\")\n            ?? throw new InvalidOperationException($\"Couldn't find type 'Stride.Core.NativeLibraryHelper' in {strideCoreAssembly}\");\n        var registerDependencyMethod = nativeLibraryHelperType.GetMethod(\"RegisterDependency\")\n            ?? throw new InvalidOperationException($\"Couldn't find method 'RegisterDependency' in {nativeLibraryHelperType}\");\n        foreach (var lib in nativeLibs)\n            registerDependencyMethod.Invoke(null, [lib]);\n    }\n\n    /// <summary>\n    /// Loads the listed native libs in Stride.Core.NativeLibraryHelper using reflection to avoid a compile time dependency on Stride.Core\n    /// </summary>\n    private static void LoadNativeDependencies(Dictionary<string, string> assemblyNameToPath, List<string> nativeLibs)\n    {\n        var strideCoreAssembly = Assembly.LoadFrom(assemblyNameToPath[\"Stride.Core\"])\n            ?? throw new InvalidOperationException(\"Couldn't find assembly 'Stride.Core' in restored packages\");\n        var nativeLibraryHelperType = strideCoreAssembly.GetType(\"Stride.Core.NativeLibraryHelper\")\n            ?? throw new InvalidOperationException($\"Couldn't find type 'Stride.Core.NativeLibraryHelper' in {strideCoreAssembly}\");\n        var preloadLibraryMethod = nativeLibraryHelperType.GetMethod(\"PreloadLibrary\")","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs#L252-L288","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the restored packages folder and confirm Stride.Core.dll exists at the mapped path.","Re-run restore cleanly (delete obj/bin/package cache for the resolver) and retry SetupNuGet.","Check that the requested package version actually contains Stride.Core in its lock file.","If assembly loading fails due to missing dependencies, ensure all lock-file assemblies were deployed, not just some."],"exampleFix":"// before: version that no longer ships Stride.Core\nSetupNuGet(packageName: \"Stride.Assets\", version: \"3.1.0\", ...);\n// after\nSetupNuGet(packageName: \"Stride.Assets\", version: \"4.2.1\", ...); // lock file includes Stride.Core","handlingStrategy":"try-catch","validationCode":"if (!File.Exists(expectedStrideCorePath))\n    throw new InvalidOperationException($\"Restored output missing Stride.Core.dll at {expectedStrideCorePath}; restore is incomplete.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    resolver.SetupNuGet(packageName, packageVersion, targetFramework);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Couldn't find assembly 'Stride.Core'\"))\n{\n    logger.Error(\"Stride.Core assembly absent from restore output; clean and re-restore with a matching package version.\");\n    throw;\n}","preventionTips":["Keep Stride.NuGetResolver and Stride runtime package versions in lockstep.","After restore, assert Stride.Core.dll exists in the output directory before proceeding.","Avoid hand-pruning the restore output directory."],"tags":["reflection","assembly-loading","nuget"],"backgroundTag":"missing-dependency","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}