{"record":{"id":"694180f4432b95a2","repo":"stride3d/stride","slug":"the-given-type-is-not-an-entitycomponent-type","errorCode":null,"errorMessage":"The given type is not an EntityComponent type","messagePattern":"The given type is not an EntityComponent type","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/Game/EditorGameComponentGizmoService.cs","lineNumber":359,"sourceCode":"\n            gizmo.IsEnabled = isVisible;\n        }\n\n        private void RemoveGizmo(IDictionary<EntityComponent, IEntityGizmo> gizmoEntities, IEntityGizmo gizmo, EntityComponent component)\n        {\n            sceneGizmos.Remove(gizmo);\n            gizmoEntities.Remove(component);\n            gizmo.Dispose();\n        }\n\n        private Type GetGizmoType(Type componentType)\n        {\n            if (componentType == null) throw new ArgumentNullException(nameof(componentType));\n            Type gizmoType;\n            while (!StrideDefaultAssetsPlugin.GizmoTypeDictionary.TryGetValue(componentType, out gizmoType))\n            {\n                componentType = componentType.BaseType;\n                if (componentType == null) throw new ArgumentException(@\"The given type is not an EntityComponent type\", nameof(componentType));\n                if (componentType == typeof(EntityComponent))\n                    return null;\n            }\n            return gizmoType;\n        }\n\n        void IEditorGameComponentGizmoViewModelService.ToggleGizmoVisibility(Type componentType, bool isVisible)\n        {\n            controller.InvokeAsync(() =>\n            {\n                var gizmoType = componentType != typeof(TransformComponent) ? GetGizmoType(componentType) : typeof(FallbackGizmo);\n                if (gizmoType == null)\n                    return;\n\n                gizmoVisibilities[gizmoType] = isVisible;\n                foreach (var gizmo in sceneGizmos)\n                {\n                    if (gizmo.GetType() == gizmoType)","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/Game/EditorGameComponentGizmoService.cs#L341-L377","documentation":"GetGizmoType walks the component type hierarchy looking up StrideDefaultAssetsPlugin.GizmoTypeDictionary; if the walk reaches a null BaseType without ever finding a gizmo type, the type is not recognized as an EntityComponent-derived type and an ArgumentException is thrown.","triggerScenarios":"Calling GetGizmoType (via gizmoType/attribute helpers in EditorGameComponentGizmoService) with a componentType that is neither registered in the gizmo dictionary nor derives from a registered type, and whose hierarchy bottoms out before hitting EntityComponent.","commonSituations":"Passing a plain class (not an EntityComponent subclass) to the gizmo resolution; building against a stride version where a component's base registration was removed; typos leading to the wrong Type being resolved.","solutions":["Pass a Type that derives (directly or indirectly) from Stride.Engine.EntityComponent","Register a gizmo type for the component type in GizmoTypeDictionary (via the StrideDefaultAssetsPlugin registration)","If the component has no gizmo, ensure its base chain reaches EntityComponent so null is returned instead of an exception","Check that the correct stride assets plugin assemblies are loaded so the dictionary is populated"],"exampleFix":"// before\nvar gizmoType = service.GetGizmoType(typeof(MyCustomThing)); // not an EntityComponent\n// after\nvar gizmoType = typeof(EntityComponent).IsAssignableFrom(typeof(MyCustomThing))\n    ? service.GetGizmoType(typeof(MyCustomThing)) : null;","handlingStrategy":"validation","validationCode":"if (componentType == null || !typeof(EntityComponent).IsAssignableFrom(componentType))\n    throw new ArgumentException(\"Type must derive from EntityComponent\", nameof(componentType));","typeGuard":"static bool IsEntityComponent(Type t) => t != null && typeof(EntityComponent).IsAssignableFrom(t);","tryCatchPattern":"try { gizmoType = GetGizmoType(componentType); }\ncatch (ArgumentException) { gizmoType = null; /* no gizmo for this type */ }","preventionTips":["Only pass EntityComponent-derived types to gizmo resolution","Register gizmo types for all custom components","Prefer treating null return (EntityComponent base hit) as 'no gizmo' rather than an error"],"tags":["csharp","reflection","editor","argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}