stride3d/stride · critical · InvalidOperationException
No GraphicsDeviceService found
Error message
No GraphicsDeviceService found
What it means
GameBase.InitializeBeforeRun, after creating the graphics device via the GraphicsDeviceManager, resolves IGraphicsDeviceService from the service registry; if absent it throws InvalidOperationException because the rest of game initialization depends on that service. It indicates the device was created but its service was never registered in Services.
Solutions
- Ensure GraphicsDeviceManager.CreateDevice() runs during initialization and registers IGraphicsDeviceService in Services
- Add the service manually: Services.AddService<IGraphicsDeviceService>(graphicsDeviceService)
- Verify you are not overriding InitializeBeforeRun in a way that bypasses base device setup
Example fix
// before Services.RemoveService<IGraphicsDeviceService>(); // or custom device path that never registers it // after graphicsDeviceManager.CreateDevice(); Services.AddService<IGraphicsDeviceService>(graphicsDeviceService);
Defensive patterns
Strategy: try-catch
Validate before calling
if (Services.GetService<IGraphicsDeviceService>() is null)
throw new InvalidOperationException("Register IGraphicsDeviceService before initializing the game"); Type guard
bool HasDeviceService(IServiceRegistry services) => services.GetService<IGraphicsDeviceService>() is not null;
Try / catch
try { game.InitializeBeforeRun(); } catch (InvalidOperationException ex) when (ex.Message.Contains("GraphicsDeviceService")) { /* log missing service and abort */ } Prevention
- Always go through GraphicsDeviceManager for device creation
- Never clear Services registrations added during initialization
When it happens
Trigger: Running a custom GameBase subclass whose Services registry lacks IGraphicsDeviceService (e.g. graphicsDeviceManager not used as intended or service registration removed/skipped).
Common situations: Replacing GraphicsDeviceManager with custom device code without registering the service; manually clearing the Services registry; engine version changes in service registration order.
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 GraphicsDevice found
- D3D12 Enhanced Barriers are required but not supported by…
- device
- No service matches the given type.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/bb681e46b961faae.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Games/GameBase.cs:365
}
internal void InitializeBeforeRun()
{
try
{
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();View on GitHub (pinned to 96fad776d2)