stride3d/stride · error · FileNotFoundException
Unable to find shader [{type}]
Error message
Unable to find shader [{type}] What it means
ShaderSourceManager.LoadShaderSource looks up a shader source by type/name among the registered shader sources; when the source is absent after all lookup attempts it throws FileNotFoundException with "Unable to find shader [{type}]" and the suggested file name "{type}.sdsl". Raised from GetShaderSourceHash's call chain when a shader's source text is needed (e.g. to compute its source hash) but no registered provider contains it.
Solutions
- Ensure the shader source is registered with ShaderSourceManager (add source/register assembly) before asking for its hash.
- Verify the shader type name string exactly matches the .sdsl file name.
- If the shader comes from an external buffer, load it through the path that populates Sources/loadedShaderSources first.
- Confirm the .sdsl file exists in a searched location and the candidate name in the exception is correct.
Example fix
// before
var hash = sourceManager.GetShaderSourceHash("MissingShader"); // FileNotFoundException
// after
if (!sourceManager.HasShaderSource("MissingShader"))
sourceManager.AddOrReplaceShaderSource("MissingShader", sdslText);
var hash = sourceManager.GetShaderSourceHash("MissingShader"); Defensive patterns
Strategy: validation
Validate before calling
// guard before asking for a hash
if (!sourceManager.HasShaderSource(type) && !File.Exists(Path.Combine(shaderDir, type + ".sdsl")))
throw new FileNotFoundException($"Register or ship shader source: {type}.sdsl"); Try / catch
try { var hash = sourceManager.GetShaderSourceHash(type); }
catch (FileNotFoundException ex) when (ex.FileName == type + ".sdsl") {
RegisterShaderSource(type, sdslText); // then retry once
} Prevention
- Register shader sources/assemblies with ShaderSourceManager at startup.
- For external/memory-loaded shaders, populate Sources before hash lookups.
- Keep shader type names in sync with .sdsl file names via build-time checks.
When it happens
Trigger: Calling LoadShaderSource(type) (directly or via GetShaderSourceHash) for a shader name that has not been added to loadedShaderSources / registered sources and cannot be found on the shader lookup path; FileNotFound carries the candidate file name {type}.sdsl.
Common situations: Hash lookup for a shader compiled from memory/external buffer that was never registered in the source manager; renamed shader; shader source assembly not referenced.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Shader {name} could not be found
- Package file [{filePath}] was not found
- Cannot detect dependencies of projet '{Name}' because the pr
- File not found inside ZIP archive.
- Unable to find the file [{url}]
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/6b4bfa5a3dd93dea.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Compilers/ShaderSourceManager.cs:220
{
sourceStream.Position = 0;
var data = new byte[sourceStream.Length];
sourceStream.ReadExactly(data, 0, (int)sourceStream.Length);
shaderSource.Hash = ObjectId.FromBytes(data);
}
else
{
shaderSource.Hash = databaseStream.ObjectId;
}
}
}
}
loadedShaderSources[type] = shaderSource;
}
else
{
throw new FileNotFoundException($"Unable to find shader [{type}]", $"{type}.sdsl");
}
}
return shaderSource;
}
}
private static ObjectId CalculateHashFromSource(string source)
{
return ObjectId.FromBytes(Encoding.UTF8.GetBytes(source));
}
/// <summary>
/// Determines whether a class with the specified type name exists.
/// </summary>
/// <param name="typeName">The typeName.</param>
/// <returns><c>true</c> if a class with the specified type name exists; otherwise, <c>false</c>.</returns>
public bool IsClassExists(string typeName)
{View on GitHub (pinned to 96fad776d2)