{"record":{"id":"2b71a5bc8ffeceab","repo":"stride3d/stride","slug":"no-graphicsdevicemanager-found","errorCode":null,"errorMessage":"No GraphicsDeviceManager found","messagePattern":"No GraphicsDeviceManager found","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"sources/engine/Stride.Games/GameBase.cs","lineNumber":427,"sourceCode":"        }\n\n        /// <summary>\n        /// Call this method to initialize the game, begin running the game loop, and start processing events for the game.\n        /// </summary>\n        /// <param name=\"gameContext\">The window Context for this game.</param>\n        /// <exception cref=\"System.InvalidOperationException\">Cannot run this instance while it is already running</exception>\n        public void Run(GameContext gameContext = null)\n        {\n            if (IsRunning)\n            {\n                throw new InvalidOperationException(\"Cannot run this instance while it is already running\");\n            }\n\n            // Gets the graphics device manager\n            graphicsDeviceManager = Services.GetService<IGraphicsDeviceManager>();\n            if (graphicsDeviceManager == null)\n            {\n                throw new InvalidOperationException(\"No GraphicsDeviceManager found\");\n            }\n\n            // Gets the GameWindow Context\n            if (gameContext == null)\n            {\n                AppContextType c;\n                if (OperatingSystem.IsWindows() && GameContextFactory.WinFormsBackendEnabled)\n                    c = AppContextType.DesktopWinForms;\n                else if (OperatingSystem.IsAndroid())\n                    c = AppContextType.Android;\n                else if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS())\n                    c = AppContextType.iOS;\n                else\n                    c = AppContextType.DesktopSDL;\n                gameContext = GameContextFactory.NewGameContext(c);\n            }\n            \n            Context = gameContext;","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Games/GameBase.cs#L409-L445","documentation":"Run() resolves the IGraphicsDeviceManager from the game's Services registry; if none is registered, the game cannot create or manage a graphics device and throws this InvalidOperationException. A GraphicsDeviceManager normally registers itself in the Game constructor.","triggerScenarios":"Instantiating GameBase directly (or a subclass) without creating a GraphicsDeviceManager and adding it to Services; removing the manager from Services before Run; custom headless setups that forgot to register IGraphicsDeviceManager.","commonSituations":"Writing a custom Game subclass and forgetting `graphicsDeviceManager = new GraphicsDeviceManager(this)` in the constructor; copy-pasting a minimal Game class that strips the manager; refactoring away the manager for testing.","solutions":["Add `new GraphicsDeviceManager(this)` in your Game subclass constructor before Run","Ensure nothing removes the IGraphicsDeviceManager from Services before Run","If truly headless, use the headless game context/appropriate GameBase variant that does not require it"],"exampleFix":"// before\npublic MyGame() { }\n// after\npublic MyGame() { graphicsDeviceManager = new GraphicsDeviceManager(this); }","handlingStrategy":"validation","validationCode":"if (game.Services.GetService<IGraphicsDeviceManager>() == null) new GraphicsDeviceManager(game);","typeGuard":null,"tryCatchPattern":"try { game.Run(); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"No GraphicsDeviceManager\")) { /* register manager and retry with new game */ }","preventionTips":["Always create GraphicsDeviceManager in the Game constructor","Never remove graphics services from the ServiceRegistry before Run","Prefer subclassing Game rather than using GameBase raw"],"tags":["graphics","dependency-injection","stride"],"backgroundTag":"missing-dependency","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"}