{"record":{"id":"d146aa0b47af6354","repo":"stride3d/stride","slug":"gamecontext-type-is-not-supported-by-the-inputmanager-d146aa","errorCode":null,"errorMessage":"GameContext type is not supported by the InputManager","messagePattern":"GameContext type is not supported by the InputManager","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Input/InputSourceFactory.cs","lineNumber":56,"sourceCode":"#endif\n#if STRIDE_PLATFORM_UWP\n                case AppContextType.UWPXaml:\n                    var uwpXamlContext = (GameContextUWPXaml)context;\n                    return new InputSourceUWP(Windows.UI.Xaml.Window.Current.CoreWindow);\n                case AppContextType.UWPCoreWindow:\n                    var uwpContext = (GameContextUWPCoreWindow)context;\n                    return new InputSourceUWP(uwpContext.Control);\n#endif\n#if (STRIDE_UI_WINFORMS || STRIDE_UI_WPF)\n                case AppContextType.DesktopWinForms:\n                    if (GameContextFactory.WinFormsBackendEnabled)\n                        return new InputSourceWinforms(((GameContextWinforms)context).Control);\n                    goto default;\n#endif\n                case AppContextType.Headless:\n                    return null; // No input source in headless mode\n                default:\n                    throw new InvalidOperationException(\"GameContext type is not supported by the InputManager\");\n            }\n        }\n    }\n}\n","sourceCodeStart":38,"sourceCodeEnd":61,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Input/InputSourceFactory.cs#L38-L61","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nvar game = new Game();\ngame.Context = new MyCustomContext(); // unknown AppContextType\n// after\nvar game = new Game(); // uses platform-appropriate GameContext automatically","handlingStrategy":"validation","validationCode":"if (context == null || !Enum.IsDefined(typeof(AppContextType), context.ContextType))\n    throw new ArgumentException(\"Unsupported GameContext for InputManager\");","typeGuard":"bool IsSupportedContext(GameContext ctx) => ctx is GameContextWinforms || ctx is GameContextSDL;","tryCatchPattern":"try { var src = InputSourceFactory.NewWindowInputSource(context); } catch (InvalidOperationException ex) { log.Error(ex); }","preventionTips":["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"],"tags":["input","csharp","factory","unsupported-type"],"backgroundTag":"unsupported-operation","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"}