{"record":{"id":"aa524fd5e5db60a4","repo":"stride3d/stride","slug":"the-disabledcommand-cannot-be-executed","errorCode":null,"errorMessage":"The DisabledCommand cannot be executed.","messagePattern":"The DisabledCommand cannot be executed\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"sources/presentation/Stride.Core.Presentation/Commands/DisabledCommand.cs","lineNumber":47,"sourceCode":"    }\n\n    /// <inheritdoc/>\n    public event EventHandler? CanExecuteChanged\n    {\n        add { }\n        remove { }\n    }\n\n    /// <inheritdoc/>\n    public bool CanExecute(object? parameter)\n    {\n        return false;\n    }\n\n    /// <inheritdoc/>\n    public void Execute(object? parameter)\n    {\n        throw new InvalidOperationException($\"The {nameof(DisabledCommand)} cannot be executed.\");\n    }\n\n    /// <inheritdoc/>\n    public void Execute()\n    {\n        throw new InvalidOperationException($\"The {nameof(DisabledCommand)} cannot be executed.\");\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":56,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation/Commands/DisabledCommand.cs#L29-L56","documentation":"A sentinel error from DisabledCommand, an ICommand whose CanExecute always returns false and whose Execute/Execute() always throw this InvalidOperationException. It exists to represent a permanently disabled command in the editor UI (button bound to it stays disabled); this error fires only if code invokes Execute directly, bypassing the CanExecute check — e.g. a programmatic Execute on a command bound to a disabled action such as Reload.","triggerScenarios":"Calling Execute(object?) on DisabledCommand, e.g. from a Button click when CanExecute checks were bypassed or the bound command was swapped to the disabled placeholder.","commonSituations":"UI invoking a command whose CanExecute returned false due to missing RequerySuggested; using DisabledCommand.None as a placeholder and forgetting to swap it.","solutions":["Check IsEnabled/CanExecute before calling Execute","Replace the DisabledCommand placeholder with a real command instance before wiring UI","Do not invoke Execute directly from code when the command may be disabled"],"exampleFix":"// before\ncommand.Execute(param); // command is DisabledCommand\n// after\nif (command.IsEnabled) command.Execute(param);","handlingStrategy":"validation","validationCode":"if (!command.IsEnabled) return; // do not invoke","typeGuard":"bool IsInvokable(ICommand c) => c.IsEnabled && c is not DisabledCommand;","tryCatchPattern":"try { command.Execute(param); } catch (InvalidOperationException) { /* command permanently disabled */ }","preventionTips":["Always check IsEnabled/CanExecute before Execute","Do not bind clickable UI directly to DisabledCommand","Replace placeholders before wiring handlers"],"tags":["csharp","command","invalid-state"],"backgroundTag":"invalid-state-transition","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"}