stride3d/stride · error · InvalidOperationException
Not initialized.
Error message
Not initialized.
What it means
GameSystemCollection.LoadContent requires the collection to be in the Initialized state; it throws this InvalidOperationException if content is loaded in any other state. This enforces the GameSystem lifecycle: Initialize -> LoadContent -> (Update/Draw).
Solutions
- Call Initialize() before LoadContent() and only once per lifecycle stage
- Check the State property before calling LoadContent
- Let GameBase drive the lifecycle automatically instead of calling methods manually
Example fix
// before systems.LoadContent(); systems.Initialize(); // after systems.Initialize(); systems.LoadContent();
Defensive patterns
Strategy: validation
Validate before calling
if (systems.State == GameSystemState.Initialized) systems.LoadContent();
Try / catch
try { systems.LoadContent(); } catch (InvalidOperationException ex) when (ex.Message == "Not initialized.") { systems.Initialize(); systems.LoadContent(); } Prevention
- Always Initialize before LoadContent
- Let GameBase drive the game-system lifecycle
- Check State before manual lifecycle calls
When it happens
Trigger: Calling LoadContent() before Initialize(), after content was already unloaded (state back to Initialized handled elsewhere), or calling it twice without an UnloadContent in between where state already advanced past Initialized.
Common situations: Manually driving the game-system lifecycle out of order in tests or custom hosts; calling LoadContent in a constructor; forgetting Initialize before LoadContent in a custom loop.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Not running.
- Already initialized.
- Unable to unload the current profile.
- Bundle has not been loaded.
- Cannot resize the manifold store, manifolds have not been…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/c80c4920c5ef9950.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Games/GameSystemCollection.cs:149
{
drawable.Key.Draw(gameTime);
drawable.Key.EndDraw();
}
}
}
}
currentlyDrawingGameSystems.Clear();
}
/// <summary>
/// Loads the content.
/// </summary>
public virtual void LoadContent()
{
if (State != GameSystemState.Initialized)
{
throw new InvalidOperationException("Not initialized.");
}
State = GameSystemState.ContentLoaded;
lock (contentableGameSystems)
{
foreach (var contentable in contentableGameSystems)
{
currentlyContentGameSystems.Add(contentable);
}
}
foreach (var contentable in currentlyContentGameSystems)
{
using (var profile = Profiler.Begin(GameProfilingKeys.GameSystemLoadContent, GetGameSystemName(contentable)))
contentable.LoadContent();
}
View on GitHub (pinned to 96fad776d2)