{"record":{"id":"c6a74f260da38fb6","repo":"stride3d/stride","slug":"not-running","errorCode":null,"errorMessage":"Not running.","messagePattern":"Not running\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Games/GameSystemCollection.cs","lineNumber":178,"sourceCode":"            }\n\n            foreach (var contentable in currentlyContentGameSystems)\n            {\n                using (var profile = Profiler.Begin(GameProfilingKeys.GameSystemLoadContent, GetGameSystemName(contentable)))\n                    contentable.LoadContent();\n            }\n\n            currentlyContentGameSystems.Clear();\n        }\n\n        /// <summary>\n        /// Called when graphics resources need to be unloaded. Override this method to unload any game-specific graphics resources.\n        /// </summary>\n        public virtual void UnloadContent()\n        {\n            if (State != GameSystemState.ContentLoaded)\n            {\n                throw new InvalidOperationException(\"Not running.\");\n            } \n            \n            State = GameSystemState.Initialized;\n\n            lock (contentableGameSystems)\n            {\n                foreach (var contentable in contentableGameSystems)\n                {\n                    currentlyContentGameSystems.Add(contentable);\n                }\n            }\n\n            foreach (var contentable in currentlyContentGameSystems)\n            {\n                contentable.UnloadContent();\n            }\n\n            currentlyContentGameSystems.Clear();","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Games/GameSystemCollection.cs#L160-L196","documentation":"GameSystemCollection.UnloadContent requires the collection to be in the ContentLoaded state; otherwise it throws this InvalidOperationException. Unloading content only makes sense after LoadContent has succeeded, so any other state is an invalid lifecycle transition.","triggerScenarios":"Calling UnloadContent() before LoadContent(), calling it twice, or calling it before Initialize on a GameSystemCollection whose State is None or Initialized.","commonSituations":"Double-unload in shutdown/cleanup code; manual lifecycle management in custom hosts; exception during LoadContent leaving state inconsistent then attempting unload.","solutions":["Only call UnloadContent when State == GameSystemState.ContentLoaded","Guard cleanup code with a state check or wrap in a lifecycle helper idempotent across states","Prefer Dispose/normal game shutdown which manages unloading correctly"],"exampleFix":"// before\nif (shutdown) { systems.UnloadContent(); }\n// after\nif (shutdown && systems.State == GameSystemState.ContentLoaded) { systems.UnloadContent(); }","handlingStrategy":"validation","validationCode":"if (systems.State == GameSystemState.ContentLoaded) systems.UnloadContent();","typeGuard":null,"tryCatchPattern":"try { systems.UnloadContent(); } catch (InvalidOperationException ex) when (ex.Message == \"Not running.\") { /* nothing to unload */ }","preventionTips":["Only unload after a successful LoadContent","Make shutdown code state-aware","Avoid double unload paths in cleanup"],"tags":["lifecycle","game-systems","invalid-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}