stride3d/stride · error · InvalidOperationException
Couldn't find method 'RegisterDependency' in
Error message
Couldn't find method 'RegisterDependency' in {nativeLibraryHelperType} What it means
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.
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.
Example fix
// before (resolver against new Stride)
GetMethod("RegisterDependency")
// after: pin runtime to resolver-compatible version
SetupNuGet("Stride.Core", resolverCompatibleVersion, targetFramework); Defensive patterns
Strategy: try-catch
Validate before calling
var t = Assembly.LoadFrom(strideCorePath).GetType("Stride.Core.NativeLibraryHelper");
if (t?.GetMethod("RegisterDependency") == null)
throw new InvalidOperationException("Stride.Core build lacks accessible RegisterDependency — incompatible with this resolver."); Type guard
static bool HasRegisterDependency(Assembly strideCore) =>
strideCore.GetType("Stride.Core.NativeLibraryHelper")
?.GetMethod("RegisterDependency") != null; Try / catch
try
{
resolver.SetupNuGet(packageName, packageVersion, targetFramework);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Couldn't find method 'RegisterDependency'"))
{
logger.Error("Stride.Core API changed: RegisterDependency missing. Align resolver and runtime versions.");
throw;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Couldn't find method 'PreloadLibrary' in
- Couldn't find type 'Stride.Core.NativeLibraryHelper' in
- An error occurred while updating the value of the node, see…
- An unknown EffectParameterClass was found.
- An unknown EffectParameterType was found.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/e8a5bf3721c3fc41.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shared/Stride.NuGetResolver/NuGetAssemblyResolver.cs:274
}
}
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")
?? throw new InvalidOperationException($"Couldn't find method 'PreloadLibrary' in {nativeLibraryHelperType}");
foreach (var lib in nativeLibs)
{
var libName = Path.GetFileNameWithoutExtension(lib);View on GitHub (pinned to 96fad776d2)