stride3d/stride · error · InvalidOperationException

Can't find a type with alias

Error message

Can't find a type with alias {typeName}; did you properly set a DataContractAttribute with this alias?

What it means

EntityChildPropertyResolver.ResolveIndexer resolves an indexer string like 'TypeName.Property' by looking up the type via DataSerializerFactory.GetTypeFromAlias. It throws InvalidOperationException when no type is registered under that alias, meaning the target class lacks a DataContractAttribute with a matching alias (or its assembly was not scanned/registered).

Solutions

  1. Add or correct [DataContract("alias")] on the target type so the alias matches the prefix used in the path.
  2. Ensure the assembly containing the type is processed by the Stride serializer/assembly registry.
  3. Check the typeName (text before the first dot) in the property path for typos.

Example fix

// before
class MyComponent : SyncScript { ... } // no alias
// after
[DataContract("MyComponent")]
class MyComponent : SyncScript { ... }
Defensive patterns

Strategy: validation

Validate before calling

var typeName = indexerName.Contains('.') ? indexerName.Substring(0, indexerName.IndexOf('.')) : indexerName;
if (DataSerializerFactory.GetTypeFromAlias(typeName) == null)
    throw new InvalidOperationException($"Type alias '{typeName}' not registered; add [DataContract(\"{typeName}\")].");

Try / catch

try { resolver.ResolveIndexer(path); }
catch (InvalidOperationException ex) { Log.Error($"Property path alias missing: {ex.Message}"); }

Prevention

When it happens

Trigger: Using an animation/script property path whose prefix before the dot does not match any DataContract alias, referencing a type in an assembly that is not registered with the serializer factory, or renaming a class without updating its alias.

Common situations: Custom component types without [DataContract("MyAlias")], AOT/trimming stripping the registration, or typos in the property key path authored in the editor.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/c490811fd81162b3. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Engine/Engine/Design/EntityChildPropertyResolver.cs:41

            get { return typeof(Entity); }
        }

        public override UpdatableMember ResolveProperty(string memberName)
        {
            return new EntityChildPropertyAccessor(memberName);
        }

        public override UpdatableMember ResolveIndexer(string indexerName)
        {
            // Note: we currently only support component with data contract aliases
            var dotIndex = indexerName.LastIndexOf('.');

            // TODO: Temporary hack to get static field of the requested type/property name
            // Need to have access to DataContract name<=>type mapping in the runtime (only accessible in Stride.Core.Design now)
            var typeName = (dotIndex == -1) ? indexerName : indexerName.Substring(0, dotIndex);
            var type = DataSerializerFactory.GetTypeFromAlias(typeName);
            if (type == null)
                throw new InvalidOperationException($"Can't find a type with alias {typeName}; did you properly set a DataContractAttribute with this alias?");

            return new EntityComponentPropertyAccessor(type);
        }

        private class EntityChildPropertyAccessor : UpdatableCustomAccessor
        {
            private readonly string childName;

            public EntityChildPropertyAccessor(string childName)
            {
                this.childName = childName;
            }

            /// <inheritdoc/>
            public override Type MemberType => typeof(Entity);

            /// <inheritdoc/>
            public override void GetBlittable(IntPtr obj, IntPtr data)

View on GitHub (pinned to 96fad776d2)