{"record":{"id":"e8a5bf3721c3fc41","repo":"stride3d/stride","slug":"couldn-t-find-method-registerdependency-in","errorCode":null,"errorMessage":"Couldn't find method 'RegisterDependency' in {nativeLibraryHelperType}","messagePattern":"Couldn't find method 'RegisterDependency' in (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs","lineNumber":274,"sourceCode":"        }\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\")\n            ?? throw new InvalidOperationException($\"Couldn't find method 'PreloadLibrary' in {nativeLibraryHelperType}\");\n        foreach (var lib in nativeLibs)\n        {\n            var libName = Path.GetFileNameWithoutExtension(lib);","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs#L256-L292","documentation":"RegisterNativeDependencies reflects for a public method named 'RegisterDependency' on Stride.Core.NativeLibraryHelper and throws an InvalidOperationException if GetMethod returns null. This is a reflected-API contract check: the loaded Stride.Core assembly does not provide the expected registration entry point.","triggerScenarios":"nativeLibraryHelperType exists but has no accessible 'RegisterDependency' method (renamed, made internal, signature moved to an overload requiring different binding flags) in the restored Stride.Core version.","commonSituations":"Stride version upgrade changing the internal native-library registration API while the NuGetResolver copy is older; using a custom Stride.Core build with the method removed.","solutions":["Use a NuGetResolver build that matches the restored Stride runtime version.","Confirm the method exists and is accessible: typeof(NativeLibraryHelper).GetMethod(\"RegisterDependency\", BindingFlags.Public|BindingFlags.Static) in a scratch console against the same DLL.","Downgrade/upgrade Stride packages to the version the resolver was compiled against.","If you own both sides, update the resolver's reflection call to the new API name/signature."],"exampleFix":"// before (resolver against new Stride)\nGetMethod(\"RegisterDependency\")\n// after: pin runtime to resolver-compatible version\nSetupNuGet(\"Stride.Core\", resolverCompatibleVersion, targetFramework);","handlingStrategy":"try-catch","validationCode":"var t = Assembly.LoadFrom(strideCorePath).GetType(\"Stride.Core.NativeLibraryHelper\");\nif (t?.GetMethod(\"RegisterDependency\") == null)\n    throw new InvalidOperationException(\"Stride.Core build lacks accessible RegisterDependency — incompatible with this resolver.\");","typeGuard":"static bool HasRegisterDependency(Assembly strideCore) =>\n    strideCore.GetType(\"Stride.Core.NativeLibraryHelper\")\n        ?.GetMethod(\"RegisterDependency\") != null;","tryCatchPattern":"try\n{\n    resolver.SetupNuGet(packageName, packageVersion, targetFramework);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Couldn't find method 'RegisterDependency'\"))\n{\n    logger.Error(\"Stride.Core API changed: RegisterDependency missing. Align resolver and runtime versions.\");\n    throw;\n}","preventionTips":["Pin exact Stride package versions (no floating ranges) so reflected APIs stay stable.","Add an integration test that exercises native dependency registration after each Stride upgrade.","Read Stride release notes for native-library API changes before bumping versions."],"tags":["reflection","method-not-found","version-mismatch"],"backgroundTag":"class-not-found","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"}