stride3d/stride · critical · InvalidOperationException
No GraphicsDeviceManager found
Error message
No GraphicsDeviceManager found
What it means
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.
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
Example fix
// before
public MyGame() { }
// after
public MyGame() { graphicsDeviceManager = new GraphicsDeviceManager(this); } Defensive patterns
Strategy: validation
Validate before calling
if (game.Services.GetService<IGraphicsDeviceManager>() == null) new GraphicsDeviceManager(game);
Try / catch
try { game.Run(); } catch (InvalidOperationException ex) when (ex.Message.Contains("No GraphicsDeviceManager")) { /* register manager and retry with new game */ } Prevention
- Always create GraphicsDeviceManager in the Game constructor
- Never remove graphics services from the ServiceRegistry before Run
- Prefer subclassing Game rather than using GameBase raw
When it happens
Trigger: 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.
Common situations: 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.
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
- Custom strides is not supported with packed PixelFormats
- A region can only be specified for Textures with…
- Cannot create a Texture View with flags
- Cannot create a Texture with format
- Cannot specify custom stride with mipmaps
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/2b71a5bc8ffeceab.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Games/GameBase.cs:427
}
/// <summary>
/// Call this method to initialize the game, begin running the game loop, and start processing events for the game.
/// </summary>
/// <param name="gameContext">The window Context for this game.</param>
/// <exception cref="System.InvalidOperationException">Cannot run this instance while it is already running</exception>
public void Run(GameContext gameContext = null)
{
if (IsRunning)
{
throw new InvalidOperationException("Cannot run this instance while it is already running");
}
// Gets the graphics device manager
graphicsDeviceManager = Services.GetService<IGraphicsDeviceManager>();
if (graphicsDeviceManager == null)
{
throw new InvalidOperationException("No GraphicsDeviceManager found");
}
// Gets the GameWindow Context
if (gameContext == null)
{
AppContextType c;
if (OperatingSystem.IsWindows() && GameContextFactory.WinFormsBackendEnabled)
c = AppContextType.DesktopWinForms;
else if (OperatingSystem.IsAndroid())
c = AppContextType.Android;
else if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS())
c = AppContextType.iOS;
else
c = AppContextType.DesktopSDL;
gameContext = GameContextFactory.NewGameContext(c);
}
Context = gameContext;View on GitHub (pinned to 96fad776d2)