stride3d/stride · warning · InvalidOperationException
The IsEnabled property of the DisabledCommand cannot be…
Error message
The IsEnabled property of the DisabledCommand cannot be modified
What it means
DisabledCommand is an immutable always-disabled command. Its IsEnabled setter throws InvalidOperationException for any `true` value; only setting it to false is tolerated. The command can never be enabled.
Solutions
- Do not attempt to enable DisabledCommand; replace the instance with a real command implementation when action is needed
- Skip DisabledCommand instances in code that enables commands in bulk
- Use CommandBase with IsEnabled toggling if dynamic enablement is required
Example fix
// before currentCommand.IsEnabled = true; // currentCommand is DisabledCommand // after if (currentCommand is not DisabledCommand) currentCommand.IsEnabled = true;
Defensive patterns
Strategy: validation
Validate before calling
if (command is DisabledCommand) return; // never attempt to enable
Type guard
bool IsEnabledMutable(ICommand c) => c is not DisabledCommand;
Try / catch
try { cmd.IsEnabled = true; } catch (InvalidOperationException) { /* DisabledCommand stays disabled */ } Prevention
- Skip DisabledCommand in bulk enable loops
- Swap in a real CommandBase when dynamic enablement is needed
- Treat DisabledCommand as a read-only singleton
When it happens
Trigger: Assigning `disabledCommand.IsEnabled = true` directly, or a view-model/framework routine that bulk-enables commands including this singleton.
Common situations: Toggle-all-commands logic, re-enabling commands after an async operation, mistakenly treating DisabledCommand as a regular configurable command.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- The DisabledCommand cannot be executed.
- This instance doesn't contain any path. Use Push() methods…
- Item belongs to another PriorityNodeQueue.
- The control corresponding to the given parentId is a…
- Invoking ShouldStayOpen before the work is finished.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/5bafdafad3a112bf.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation/Commands/DisabledCommand.cs:28
public sealed class DisabledCommand : ICommandBase
{
/// <summary>
/// Gets a singleton instance of the <see cref="DisabledCommand"/>
/// </summary>
public static DisabledCommand Instance { get; } = new DisabledCommand();
/// <summary>
/// Initializes a new instance of the <see cref="DisabledCommand"/> class.
/// </summary>
private DisabledCommand()
{
}
/// <inheritdoc/>
public bool IsEnabled
{
get { return false; }
set { if (!value) throw new InvalidOperationException($"The {nameof(IsEnabled)} property of the {nameof(DisabledCommand)} cannot be modified"); }
}
/// <inheritdoc/>
public event EventHandler? CanExecuteChanged
{
add { }
remove { }
}
/// <inheritdoc/>
public bool CanExecute(object? parameter)
{
return false;
}
/// <inheritdoc/>
public void Execute(object? parameter)
{View on GitHub (pinned to 96fad776d2)