stride3d/stride · error · InvalidOperationException
Simulated Mouse does not exist
Error message
Simulated Mouse does not exist
What it means
InputSourceSimulated.RemoveMouse requires the MouseSimulated instance to currently be in the source's mice collection. If the mouse was never created by this source or was already removed, the membership check fails and InvalidOperationException is thrown.
Solutions
- Only remove MouseSimulated instances created by this source
- Track removed instances or check membership before removal
- Prefer RemoveAllMice for full teardown
- Null out references after removal to avoid stale reuse
Example fix
// before source.RemoveMouse(mouse); source.RemoveMouse(mouse); // throws // after if (mice.Contains(mouse)) source.RemoveMouse(mouse);
Defensive patterns
Strategy: validation
Validate before calling
if (createdMice.Contains(mouse)) source.RemoveMouse(mouse);
Try / catch
try { source.RemoveMouse(mouse); } catch (InvalidOperationException) { /* already removed */ } Prevention
- Only remove mice you created from this same source instance
- Drop references after removal
- Use RemoveAllMice for teardown
When it happens
Trigger: Calling RemoveMouse with a mouse not created via this source's CreateMouse, or a second RemoveMouse call for an already-removed instance.
Common situations: Double teardown in test fixtures; stale references after RemoveAllMice; passing simulated mice between different InputSourceSimulated instances.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Simulated GamePad does not exist
- Simulated Keyboard does not exist
- Simulated PointerDevice does not exist
- Can not set more than one button at a time
- The given does not correspond to any existing part.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/86a1bab41be843d1.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Input/Simulated/InputSourceSimulated.cs:72
public void RemoveAllGamePads()
{
foreach (var gamePad in gamePads)
UnregisterDevice(gamePad);
gamePads.Clear();
}
public MouseSimulated AddMouse()
{
var mouse = new MouseSimulated(this);
mice.Add(mouse);
RegisterDevice(mouse);
return mouse;
}
public void RemoveMouse(MouseSimulated mouse)
{
if (!mice.Contains(mouse))
throw new InvalidOperationException("Simulated Mouse does not exist");
UnregisterDevice(mouse);
mice.Remove(mouse);
}
public void RemoveAllMice()
{
foreach (var mouse in mice)
UnregisterDevice(mouse);
mice.Clear();
}
public KeyboardSimulated AddKeyboard()
{
var keyboard = new KeyboardSimulated(this);
keyboards.Add(keyboard);
RegisterDevice(keyboard);
return keyboard;
}View on GitHub (pinned to 96fad776d2)