{"record":{"id":"3799b09b8889f288","repo":"stride3d/stride","slug":"the-service-service-gettype-name-requires-a-service-of-type","errorCode":null,"errorMessage":"The service [{service.GetType().Name}] requires a service of type [{dependency.Name}] to be initialized first.","messagePattern":"The service \\[(.+?)\\] requires a service of type \\[(.+?)\\] to be initialized first\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/Game/EntityHierarchyEditorGame.cs","lineNumber":307,"sourceCode":"                    Diffuse = new MaterialDiffuseMapFeature(new ComputeTextureColor { FallbackValue = null }), // Do not use fallback value, we want a DiffuseMap\n                    DiffuseModel = new MaterialDiffuseLambertModelFeature()\n                }\n            });\n\n            // Listen to all Renderer Initialized to plug dynamic effect compilation\n            RenderContext.GetShared(Services).RendererInitialized += SceneGameRendererInitialized;\n            // Update the marker render target setter viewport\n            //OnClientSizeChanged(this, EventArgs.Empty);\n\n            // Initialize the services\n            var initialized = new List<IEditorGameService>();\n            foreach (var service in EditorServices.OrderByDependency())\n            {\n                // Check that the current service dependencies have been initialized\n                foreach (var dependency in service.Dependencies)\n                {\n                    if (!initialized.Any(x => dependency.IsInstanceOfType(x)))\n                        throw new InvalidOperationException($\"The service [{service.GetType().Name}] requires a service of type [{dependency.Name}] to be initialized first.\");\n                }\n                if (await service.InitializeService(this))\n                {\n                    initialized.Add(service);\n                }\n\n                var mouseService = service as EditorGameMouseServiceBase;\n                mouseService?.RegisterMouseServices(EditorServices);\n            }\n\n            // TODO: Maybe define this scene default graphics compositor as an asset?\n            var defaultGraphicsCompositor = GraphicsCompositorHelper.CreateDefault(true, EditorGraphicsCompositorHelper.EditorForwardShadingEffect);\n\n            // Add UI (engine doesn't depend on it)\n            defaultGraphicsCompositor.RenderFeatures.Add(new UIRenderFeature\n            {\n                RenderStageSelectors =\n                {","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/Game/EntityHierarchyEditorGame.cs#L289-L325","documentation":"EntityHierarchyEditorGame.LoadContent initializes editor services in dependency order (OrderByDependency). Before initializing each service it verifies every declared dependency type is present in the already-initialized list; if not, an InvalidOperationException is thrown, because initializing a service without its dependency would leave it broken.","triggerScenarios":"Registering an editor service whose Dependencies include a type that is never registered or whose initializing service failed (InitializeService returned false, so it was not added to initialized).","commonSituations":"Forgetting to register a dependency service in the editor game setup; a required service's InitializeService returning false (e.g. missing game settings) so the dependent cannot initialize; wrong registration order in custom editor bootstraps.","solutions":["Register all services listed in the failing service's Dependencies before it in the editor game service collection","Check logs to see why the dependency's InitializeService returned false and fix that root cause","Ensure the dependency type matches exactly the interface/class declared in Dependencies","Verify no custom OrderByDependency/regISTRATION code filters out the dependency"],"exampleFix":"// before\neditorGame.EditorServices.Add(new EditorGameNavigationMeshService()); // depends on GameSettingsProviderService\n// after\neditorGame.EditorServices.Add(new GameSettingsProviderService(...));\neditorGame.EditorServices.Add(new EditorGameNavigationMeshService());","handlingStrategy":"validation","validationCode":"var missing = service.Dependencies.Where(d => !editorGame.EditorServices.Any(s => d.IsInstanceOfType(s))).ToList();\nif (missing.Any()) throw new InvalidOperationException(\"Unregistered dependencies: \" + string.Join(\",\", missing));","typeGuard":null,"tryCatchPattern":"try { await editorGame.LoadContent(); }\ncatch (InvalidOperationException ex) { log.Critical(ex); DisableEditorServices(); }","preventionTips":["Register every service listed in a service's Dependencies","Check InitializeService return values; a false return cascades to dependent failures","Keep dependency declarations minimal and documented"],"tags":["csharp","editor","dependency-order","initialization"],"backgroundTag":"missing-dependency","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"}