{"record":{"id":"45d12286ccca71c4","repo":"stride3d/stride","slug":"no-graphicsdevice-found","errorCode":null,"errorMessage":"No GraphicsDevice found","messagePattern":"No GraphicsDevice found","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"sources/engine/Stride.Games/GameBase.cs","lineNumber":371,"sourceCode":"                using (var profile = Profiler.Begin(GameProfilingKeys.GameInitialize))\n                {\n                    // Initialize this instance and all game systems before trying to create the device.\n                    Initialize();\n\n                    // Make sure that the device is already created\n                    graphicsDeviceManager.CreateDevice();\n\n                    // Gets the graphics device service\n                    graphicsDeviceService = Services.GetService<IGraphicsDeviceService>();\n                    if (graphicsDeviceService == null)\n                    {\n                        throw new InvalidOperationException(\"No GraphicsDeviceService found\");\n                    }\n\n                    // Checks the graphics device\n                    if (graphicsDeviceService.GraphicsDevice == null)\n                    {\n                        throw new InvalidOperationException(\"No GraphicsDevice found\");\n                    }\n\n                    // Setup the graphics device if it was not already setup.\n                    SetupGraphicsDeviceEvents();\n\n                    // Drain pending GPU work before the window is destroyed: a queued flip-model\n                    // Present can only complete while its window is alive, and the device is\n                    // destroyed after the window on the exit path.\n                    Window.Closing += (_, _) => GraphicsDevice?.WaitForGpuIdle();\n\n                    // Bind Graphics Context enabling initialize to use GL API eg. SetData to texture ...etc\n                    BeginDraw();\n\n                    LoadContentInternal();\n\n                    IsRunning = true;\n\n                    BeginRun();","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Games/GameBase.cs#L353-L389","documentation":"Immediately after resolving IGraphicsDeviceService, GameBase.InitializeBeforeRun checks that GraphicsDevice is non-null; a null device means the service exists but no device was actually created or it was already disposed. Throws InvalidOperationException.","triggerScenarios":"IGraphicsDeviceService is registered but its GraphicsDevice property is null — device creation failed silently, the device was disposed, or a stub service was registered.","commonSituations":"Custom IGraphicsDeviceService implementations returning null; headless/CI environments where device creation fails; double-dispose of the game before initialization completes.","solutions":["Verify GraphicsDeviceManager.CreateDevice() succeeded before running the game","Check device-creation logs/exceptions (driver or GPU support issues) in CI environments","Ensure a real GraphicsDevice is assigned to the registered IGraphicsDeviceService","Avoid disposing the device between CreateDevice and InitializeBeforeRun"],"exampleFix":"// before\nServices.AddService<IGraphicsDeviceService>(new StubDeviceService()); // GraphicsDevice == null\n// after\nvar service = new StubDeviceService { GraphicsDevice = graphicsDevice };\nServices.AddService<IGraphicsDeviceService>(service);","handlingStrategy":"validation","validationCode":"var svc = Services.GetService<IGraphicsDeviceService>();\nif (svc?.GraphicsDevice is null)\n    throw new InvalidOperationException(\"GraphicsDevice was not created or is disposed\");","typeGuard":"bool HasLiveDevice(IServiceRegistry s) => s.GetService<IGraphicsDeviceService>()?.GraphicsDevice is not null;","tryCatchPattern":"try { game.InitializeBeforeRun(); } catch (InvalidOperationException ex) when (ex.Message == \"No GraphicsDevice found\") { /* log device creation failure, check drivers */ }","preventionTips":["Confirm CreateDevice succeeded and logged no errors before running","In CI/headless environments verify GPU/driver availability","Avoid disposing the device between creation and game initialization"],"tags":["game","graphics-device","null-reference"],"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"}