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

  1. Verify the template description's factory type/id is correct and that the assembly providing the factory is loaded
  2. Check the associated AssetFactory is registered (AttributeRegistry / factory registration ran) before the template is used
  3. 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

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


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)