stride3d/stride · critical · InvalidOperationException
No GraphicsDevice found
Error message
No GraphicsDevice found
What it means
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.
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
Example fix
// before
Services.AddService<IGraphicsDeviceService>(new StubDeviceService()); // GraphicsDevice == null
// after
var service = new StubDeviceService { GraphicsDevice = graphicsDevice };
Services.AddService<IGraphicsDeviceService>(service); Defensive patterns
Strategy: validation
Validate before calling
var svc = Services.GetService<IGraphicsDeviceService>();
if (svc?.GraphicsDevice is null)
throw new InvalidOperationException("GraphicsDevice was not created or is disposed"); Type guard
bool HasLiveDevice(IServiceRegistry s) => s.GetService<IGraphicsDeviceService>()?.GraphicsDevice is not null;
Try / catch
try { game.InitializeBeforeRun(); } catch (InvalidOperationException ex) when (ex.Message == "No GraphicsDevice found") { /* log device creation failure, check drivers */ } Prevention
- 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
When it happens
Trigger: IGraphicsDeviceService is registered but its GraphicsDevice property is null — device creation failed silently, the device was disposed, or a stub service was registered.
Common situations: Custom IGraphicsDeviceService implementations returning null; headless/CI environments where device creation fails; double-dispose of the game before initialization completes.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- No GraphicsDeviceService found
- ArgumentNullException
- ArgumentNullException: descriptions
- ArgumentNullException: paramName
- ArgumentNullException: value
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/45d12286ccca71c4.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Games/GameBase.cs:371
using (var profile = Profiler.Begin(GameProfilingKeys.GameInitialize))
{
// Initialize this instance and all game systems before trying to create the device.
Initialize();
// Make sure that the device is already created
graphicsDeviceManager.CreateDevice();
// Gets the graphics device service
graphicsDeviceService = Services.GetService<IGraphicsDeviceService>();
if (graphicsDeviceService == null)
{
throw new InvalidOperationException("No GraphicsDeviceService found");
}
// Checks the graphics device
if (graphicsDeviceService.GraphicsDevice == null)
{
throw new InvalidOperationException("No GraphicsDevice found");
}
// Setup the graphics device if it was not already setup.
SetupGraphicsDeviceEvents();
// Drain pending GPU work before the window is destroyed: a queued flip-model
// Present can only complete while its window is alive, and the device is
// destroyed after the window on the exit path.
Window.Closing += (_, _) => GraphicsDevice?.WaitForGpuIdle();
// Bind Graphics Context enabling initialize to use GL API eg. SetData to texture ...etc
BeginDraw();
LoadContentInternal();
IsRunning = true;
BeginRun();View on GitHub (pinned to 96fad776d2)