stride3d/stride · error · ArgumentException

The given component type does not inherit from…

Error message

The given component type does not inherit from EntityComponent.

What it means

CreateEntityComponentPickerDialog validates that the component type passed to the entity picker is a concrete subclass of EntityComponent. The guard throws ArgumentException when the type does not inherit from EntityComponent AND is not abstract, since a concrete non-EntityComponent type cannot be used to pick/create entities.

Solutions

  1. Pass a concrete Type that derives from Stride.Engine.EntityComponent, e.g. typeof(MyComponent)
  2. Check the type with typeof(EntityComponent).IsAssignableFrom(componentType) before calling, and skip or adapt for abstract types
  3. If you intended an abstract type, note the guard only accepts it when componentType.IsAbstract is true; verify you are not passing a concrete unrelated type

Example fix

// before
dialogService.CreateEntityComponentPickerDialog(editor, typeof(MyViewModel));
// after
dialogService.CreateEntityComponentPickerDialog(editor, typeof(MyEntityComponent));
Defensive patterns

Strategy: validation

Validate before calling

bool ok = componentType != null && (typeof(EntityComponent).IsAssignableFrom(componentType) || componentType.IsAbstract);
if (!ok) throw new ArgumentException(nameof(componentType));

Type guard

bool IsConcreteEntityComponent(Type t) => t != null && typeof(EntityComponent).IsAssignableFrom(t) && !t.IsAbstract;

Try / catch

try { var dlg = svc.CreateEntityComponentPickerDialog(editor, componentType); }
catch (ArgumentException) { // fall back to default picker or show validation message
}

Prevention

When it happens

Trigger: Calling StrideDialogService.CreateEntityComponentPickerDialog with a componentType that is a concrete type not derived from EntityComponent (e.g. passing a ViewModel, a TransformComponent-like unrelated class, or the wrong Type object entirely).

Common situations: Plugin/extension developers wiring custom picker dialogs pass typeof(SomeViewModel) or a base class instead of their concrete EntityComponent subclass; refactoring renames/moves component classes and stale Type references get passed.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/SceneEditor/Services/StrideDialogService.cs:29

    /// <summary>
    /// This class is the default implementation of the <see cref="IStrideDialogService"/>.
    /// </summary>
    internal class StrideDialogService : IStrideDialogService
    {
        /// <inheritdoc/>
        public IEntityPickerDialog CreateEntityPickerDialog(EntityHierarchyEditorViewModel editor)
        {
            if (editor == null) throw new ArgumentNullException(nameof(editor));
            var picker = new EntityPickerWindow(editor, null);
            return picker;
        }

        /// <inheritdoc/>
        public IEntityPickerDialog CreateEntityComponentPickerDialog(EntityHierarchyEditorViewModel editor, Type componentType)
        {
            if (editor == null) throw new ArgumentNullException(nameof(editor));
            if (!typeof(EntityComponent).IsAssignableFrom(componentType) && componentType.IsAbstract == false)
                throw new ArgumentException(@"The given component type does not inherit from EntityComponent.", nameof(componentType));

            var picker = new EntityPickerWindow(editor, componentType);
            return picker;
        }
    }
}

View on GitHub (pinned to 96fad776d2)