stride3d/stride · error · InvalidOperationException
Unable to find/generate key
Error message
Unable to find/generate key [{0}] with unsupported type [{1}/{2}] What it means
Effect.ResolveResourceKey throws InvalidOperationException when it cannot generate a resource binding key for a shader parameter: the parameter's resource class and type combination is not handled by the key-generation switch, leaving keyInfo.Key null. Usually means the effect was compiled with a parameter type the runtime binding layer does not know.
Solutions
- Recompile all shaders and rebuild the effects database with the same Stride version as the runtime.
- Check the failing parameter's shader declaration and change it to a supported type (Texture2D, Sampler, constant buffer member types).
- Verify engine/runtime version consistency — rebuild custom effect code after a Stride upgrade.
- Inspect keyInfo.KeyName in the message to locate the offending shader parameter and fix its declaration.
Example fix
// before (custom/unrecognized type in shader) my_custom_resource customRes; // after Texture2D myTexture : register(t0); // use a supported resource type
Defensive patterns
Strategy: try-catch
Validate before calling
try
{
effect.InitializeFrom(device, bytecode);
}
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Unable to find/generate key"))
{
log.Error($"Unsupported shader parameter on effect {bytecode?.SourceFilename}: {ex.Message}");
} Type guard
bool HasKnownParameterTypes(Effect effect) =>
effect.Description.EffectKeys.All(k => IsSupportedResourceClass(k.Class, k.Type)); Try / catch
try { var effect = new Effect(device, bytecode); }
catch (InvalidOperationException ex) when (ex.Message.Contains("unsupported type"))
{ log.Error(ex, "Recompile shaders with the current Stride version"); throw; } Prevention
- Recompile shaders and rebuild the effects database after every Stride upgrade.
- Use only resource types the runtime binding layer supports in custom shaders.
- Pin the same Stride version across shader compilation and runtime execution.
- Log the parameter name from the message to quickly find the offending shader declaration.
When it happens
Trigger: Loading/initializing an effect whose EffectValueDescription has a Class/Type pair outside the supported set (e.g. an unrecognized TextureType/class, new shader parameter kind, or a corrupted/mismatched effects database) while resolving keys during UpdateResourceBindingKey/UpdateResourceEntryKey.
Common situations: Custom shader plugins introducing new parameter types; effects compiled by a newer Stride version than the runtime; stale or mismatched compiled-effect assets after engine upgrade.
Related errors
- bytecode
- Could not find function
- Couldn't find method 'PreloadLibrary' in
- Couldn't find method 'RegisterDependency' in
- Couldn't find type 'Stride.Core.NativeLibraryHelper' in
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b29ecba5ee16c19c.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Effects/Effect.cs:266
case EffectParameterType.Texture2D:
case EffectParameterType.Texture2DArray:
case EffectParameterType.Texture2DMultisampled:
case EffectParameterType.Texture2DMultisampledArray:
case EffectParameterType.RWTexture2D:
case EffectParameterType.RWTexture2DArray:
case EffectParameterType.TextureCube:
case EffectParameterType.TextureCubeArray:
case EffectParameterType.RWTexture3D:
case EffectParameterType.Texture3D:
keyInfo.Key = FindOrCreateResourceKey<Texture>(keyName);
break;
}
break;
}
if (keyInfo.Key == null)
{
throw new InvalidOperationException(string.Format("Unable to find/generate key [{0}] with unsupported type [{1}/{2}]", keyInfo.KeyName, @class, type));
}
}
private static void UpdateValueBindingKey(ref EffectValueDescription binding)
{
switch (binding.Type.Class)
{
case EffectParameterClass.Scalar:
switch (binding.Type.Type)
{
case EffectParameterType.Bool:
binding.KeyInfo.Key = FindOrCreateValueKey<bool>(ref binding);
break;
case EffectParameterType.Int:
binding.KeyInfo.Key = FindOrCreateValueKey<int>(ref binding);
break;
case EffectParameterType.UInt:
binding.KeyInfo.Key = FindOrCreateValueKey<uint>(ref binding);View on GitHub (pinned to 96fad776d2)