stride3d/stride · error · InvalidOperationException
Unable to find the asset factory associated to this…
Error message
Unable to find the asset factory associated to this template.
What it means
AssetFactoryTemplateGenerator.CreateAssets resolves the asset factory from the template's TemplateAssetFactoryDescription via GetFactory(). When the description yields no factory, it throws InvalidOperationException because it cannot create the template's assets.
Solutions
- Verify the template description's factory type/id is correct and that the assembly providing the factory is loaded
- Check the associated AssetFactory is registered (AttributeRegistry / factory registration ran) before the template is used
- Update or rewrite the custom template to match the current Stride template-description schema
Example fix
// before description.Factory = null; // or unresolved type string // after description.Factory = typeof(MyAssetFactory); // concrete registered factory
Defensive patterns
Strategy: type-guard
Validate before calling
var factory = desc?.GetFactory();
if (factory == null) { /* handle missing factory before proceeding */ } Type guard
bool HasFactory(TemplateAssetFactoryDescription d) => d?.GetFactory() != null;
Try / catch
try { foreach (var a in gen.CreateAssets(parameters)) yield return a; }
catch (InvalidOperationException) { // report template misconfiguration in the UI
} Prevention
- Ensure the assembly containing the AssetFactory is referenced and loaded by the editor
- Test custom templates by actually applying them, not just registering them
- Keep template factory type references in sync with the current Stride API version
When it happens
Trigger: Applying a new-asset template whose TemplateAssetFactoryDescription.GetFactory() returns null — e.g. the template description references a factory type/id that is not registered or fails to resolve.
Common situations: Custom asset templates written for a different Stride version whose factory registration no longer resolves; template description typos or missing plugin assemblies at editor startup.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Asset returned by CreateAssets has no location. Use…
- An IMemberNode was expected when processing the path
- An IObjectNode was expected when processing the path
- An item has been added to a collection that does not have a…
- Custom strides is not supported with packed PixelFormats
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/de9676c01e6ea347.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/Templates/AssetFactoryTemplateGenerator.cs:28
public class AssetFactoryTemplateGenerator : AssetTemplateGenerator
{
public static readonly AssetFactoryTemplateGenerator Default = new AssetFactoryTemplateGenerator();
public override bool IsSupportingTemplate(TemplateDescription templateDescription)
{
if (templateDescription == null) throw new ArgumentNullException(nameof(templateDescription));
return templateDescription is TemplateAssetFactoryDescription;
}
protected override IEnumerable<AssetItem> CreateAssets(AssetTemplateGeneratorParameters parameters)
{
var desc = parameters.Description as TemplateAssetFactoryDescription;
if (desc == null)
yield break;
var factory = desc.GetFactory();
if (factory == null)
throw new InvalidOperationException("Unable to find the asset factory associated to this template.");
var asset = factory.New();
yield return new AssetItem(GenerateLocation(parameters), asset);
}
}
}
View on GitHub (pinned to 96fad776d2)