stride3d/stride · error · InvalidOperationException
GameContext type is not supported by the InputManager
Error message
GameContext type is not supported by the InputManager
What it means
InputSourceFactory.NewWindowInputSource maps an AppContextType to a concrete InputSource (Winforms, SDL, etc.). When the GameContext's context type has no matching case, the factory throws InvalidOperationException. It means the input system cannot create an input source for the provided game context.
Solutions
- Use a supported GameContext (GameContextWinforms/GameContextSDL or platform-appropriate one)
- Verify the AppContextType of your context matches a case compiled into your target platform
- For headless contexts expect null (no input source) rather than a factory exception; check where the context was constructed
- If using a custom context, contribute a case in InputSourceFactory or file/patch the switch
Example fix
// before var game = new Game(); game.Context = new MyCustomContext(); // unknown AppContextType // after var game = new Game(); // uses platform-appropriate GameContext automatically
Defensive patterns
Strategy: validation
Validate before calling
if (context == null || !Enum.IsDefined(typeof(AppContextType), context.ContextType))
throw new ArgumentException("Unsupported GameContext for InputManager"); Type guard
bool IsSupportedContext(GameContext ctx) => ctx is GameContextWinforms || ctx is GameContextSDL;
Try / catch
try { var src = InputSourceFactory.NewWindowInputSource(context); } catch (InvalidOperationException ex) { log.Error(ex); } Prevention
- Let Stride create the default GameContext for the platform instead of hand-constructing one
- Check AppContextType compatibility when targeting multiple platforms with conditional compilation
- Avoid custom GameContext subclasses unless you also extend the factory
When it happens
Trigger: Passing a GameContext whose AppContextType is not one of the supported types handled above the default case (e.g. a custom or newer context type, or a context type guarded by a #if platform define that is not compiled in).
Common situations: Running a Winforms-targeted build on a platform where that case is compiled out; custom GameContext implementations that don't set a recognized AppContextType; upgrading Stride and introducing a context type the factory's switch doesn't cover.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Type [ ] is not supported as a modifiable collection
- factory
- Unsupported Graphics Resource. Only Textures, Buffers and…
- value
- value
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/d146aa0b47af6354.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Input/InputSourceFactory.cs:56
#endif
#if STRIDE_PLATFORM_UWP
case AppContextType.UWPXaml:
var uwpXamlContext = (GameContextUWPXaml)context;
return new InputSourceUWP(Windows.UI.Xaml.Window.Current.CoreWindow);
case AppContextType.UWPCoreWindow:
var uwpContext = (GameContextUWPCoreWindow)context;
return new InputSourceUWP(uwpContext.Control);
#endif
#if (STRIDE_UI_WINFORMS || STRIDE_UI_WPF)
case AppContextType.DesktopWinForms:
if (GameContextFactory.WinFormsBackendEnabled)
return new InputSourceWinforms(((GameContextWinforms)context).Control);
goto default;
#endif
case AppContextType.Headless:
return null; // No input source in headless mode
default:
throw new InvalidOperationException("GameContext type is not supported by the InputManager");
}
}
}
}
View on GitHub (pinned to 96fad776d2)