{"record":{"id":"3325f74bc45bdc02","repo":"stride3d/stride","slug":"requested-type-and-current-platform-are-incompatible","errorCode":null,"errorMessage":"Requested type and current platform are incompatible.","messagePattern":"Requested type and current platform are incompatible\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Games/GameContextFactory.cs","lineNumber":70,"sourceCode":"                    res = NewGameContextWpf(requestedWidth, requestedHeight, isUserManagingRun);\n                    break;\n                case AppContextType.UWPXaml:\n                    res = NewGameContextUWPXaml(requestedWidth, requestedHeight);\n                    break;\n                case AppContextType.UWPCoreWindow:\n                    res = NewGameContextUWPCoreWindow(requestedWidth, requestedHeight);\n                    break;\n                case AppContextType.iOS:\n                    res = NewGameContextiOS();\n                    break;\n                case AppContextType.Headless:\n                    res = new GameContextHeadless(requestedWidth, requestedHeight);\n                    break;\n            }\n\n            if (res == null)\n            {\n                throw new InvalidOperationException(\"Requested type and current platform are incompatible.\");\n            }\n\n            return res;\n        }\n\n        public static GameContext NewGameContextiOS()\n        {\n#if STRIDE_PLATFORM_IOS\n            return new GameContextiOS(null);\n#else\n            return null;\n#endif\n        }\n\n        public static GameContext NewGameContextAndroid()\n        {\n#if STRIDE_PLATFORM_ANDROID\n            return new GameContextAndroid(null, null);","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Games/GameContextFactory.cs#L52-L88","documentation":"GameContextFactory.NewGameContext tries to build a GameContext matching the requested GameContextType (windowed, offscreen, headless, etc.) for the current platform. If no context implementation matches, res stays null and this InvalidOperationException is thrown, meaning the requested context type has no implementation on the running platform.","triggerScenarios":"Requesting AppContextType.Window (or a type with no implementation) on a platform where that context type is unsupported, e.g. requesting a windowed context on a headless/unsupported platform; passing an invalid/unmapped GameContextType.","commonSituations":"Running a windowed game on a server/CI machine without window support; custom platform targets lacking a context implementation; misconfigured game settings choosing an unavailable context type.","solutions":["Request a supported GameContextType for the platform (e.g. Headless on servers)","Add platform detection and select the context type conditionally before calling Run","If targeting a custom platform, implement and register the corresponding GameContext factory branch"],"exampleFix":"// before\nvar ctx = GameContextFactory.NewGameContext(GameContextType.Window);\n// after\nvar ctx = GameContextFactory.NewGameContext(Environment.UserInteractive ? GameContextType.Window : GameContextType.Headless);","handlingStrategy":"validation","validationCode":"var type = Environment.UserInteractive ? GameContextType.Window : GameContextType.Headless;\nvar ctx = GameContextFactory.NewGameContext(type);","typeGuard":null,"tryCatchPattern":"try { ctx = GameContextFactory.NewGameContext(requested); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"platform are incompatible\")) { ctx = GameContextFactory.NewGameContext(GameContextType.Headless); }","preventionTips":["Select context type based on platform capabilities","Avoid hardcoding windowed contexts in servers/CI","Test on every target platform before release"],"tags":["platform","game-context","stride"],"backgroundTag":"unsupported-platform","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}