stride3d/stride · error · Exception
Can not construct gizmo of type
Error message
Can not construct gizmo of type {gizmoType}, it does not have a constructor taking a single EntityComponent What it means
DispatcherGizmo.Update instantiates a gizmo object via Activator.CreateInstance when the edited component type changes. Gizmo types must expose a constructor taking exactly one EntityComponent parameter; if the registered gizmo type's constructor does not match, reflection-based construction is impossible and a plain Exception is thrown.
Solutions
- Add a constructor to the gizmo type accepting a single EntityComponent (or the exact component type registered) and delegate to the base constructor.
- Check the gizmo type's registration/attribute points at the intended gizmo class, not an abstract helper type.
- Unit-test gizmo construction with Activator.CreateInstance in a plugin's startup to fail early.
Example fix
// before
public class MyGizmo : EntityGizmo<MyComponent>
{
public MyGizmo() { } // no EntityComponent ctor
}
// after
public class MyGizmo : EntityGizmo<MyComponent>
{
public MyGizmo(EntityComponent component) : base(component) { }
} Defensive patterns
Strategy: validation
Validate before calling
if (gizmoType.GetConstructor(new[] { typeof(EntityComponent) }) == null)
throw new InvalidOperationException($"{gizmoType} must have a single EntityComponent constructor."); Type guard
bool IsValidGizmoType(Type t) => !t.IsAbstract && t.GetConstructor(new[] { typeof(EntityComponent) }) != null; Try / catch
try { currentGizmo = (EntityGizmo<TComponent>)Activator.CreateInstance(gizmoType, Component); }
catch (Exception ex) { log.Error($"Bad gizmo type {gizmoType}: {ex.Message}"); } Prevention
- Always give custom gizmos a public ctor taking EntityComponent
- Scan registered gizmo types at plugin startup with reflection
- Keep gizmo constructors aligned with the base EntityGizmo pattern
When it happens
Trigger: Registering or attributing a custom EntityGizmo<TComponent> whose constructor signature differs (e.g. parameterless ctor, extra parameters, or ctor taking a derived component type not matching typeof(EntityComponent) exactly for the reflection probe).
Common situations: Writing a custom gizmo for a custom entity component and forgetting the (EntityComponent) constructor; copy-pasting a gizmo class and changing its constructor; signature drift after refactoring base classes.
Related errors
- The associated asset type does not have a public…
- Type [ ] is not a primitive
- Type [ ] is not a primitive
- Type has no empty ctor
- IEntityGizmo ' ' must have a constructor with exactly one…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/1126dc18e7277f33.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/Gizmos/DispatcherGizmo.cs:95
if (currentGizmoType != gizmoType)
{
// Delete the old gizmo
if (currentGizmo != null)
{
currentGizmo.Dispose();
currentGizmo = null;
}
// Create the new gizmo
if (gizmoType != null && typeof(IGizmo).IsAssignableFrom(gizmoType))
{
if (gizmoType.GetConstructor(new[] { typeof(EntityComponent) }) != null)
{
currentGizmo = (EntityGizmo<TComponent>)Activator.CreateInstance(gizmoType, Component);
}
else
{
throw new Exception($"Can not construct gizmo of type {gizmoType}, it does not have a constructor taking a single {nameof(EntityComponent)}");
}
}
// Initialize the new gizmo
currentGizmo?.Initialize(Services, EditorScene);
// Set the selected and enabled state of the gizmo
IsSelected = IsSelected;
IsEnabled = IsEnabled;
}
currentGizmoType = gizmoType;
// update the current gizmo
currentGizmo?.Update();
}
protected override void Destroy()
{View on GitHub (pinned to 96fad776d2)