{"record":{"id":"d87c8b3c94528500","repo":"stride3d/stride","slug":"registry","errorCode":null,"errorMessage":"registry","messagePattern":"registry","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Engine/Engine/EntityManager.cs","lineNumber":83,"sourceCode":"\n        /// <summary>\n        /// Occurs when a new component type is added.\n        /// </summary>\n        public event EventHandler<TypeInfo> ComponentTypeAdded;\n\n        /// <summary>\n        /// Occurs when a component changed for an entity (Added or removed)\n        /// </summary>\n        public event EventHandler<EntityComponentEventArgs> ComponentChanged;\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"EntityManager\"/> class.\n        /// </summary>\n        /// <param name=\"registry\">The registry.</param>\n        /// <exception cref=\"System.ArgumentNullException\">registry</exception>\n        protected EntityManager(IServiceRegistry registry)\n        {\n            if (registry == null) throw new ArgumentNullException(\"registry\");\n            Services = registry;\n\n            entities = new HashSet<Entity>();\n            processors = new TrackingEntityProcessorCollection(this);\n            pendingProcessors = new EntityProcessorCollection();\n\n            componentTypes = new HashSet<TypeInfo>();\n            MapComponentTypeToProcessors = new Dictionary<TypeInfo, EntityProcessorCollectionPerComponentType>();\n\n            currentDependentProcessors = new List<EntityProcessor>(10);\n\n            flexibleProcessors = new ProcessorManager(registry);\n        }\n\n        /// <summary>\n        /// Gets the services.\n        /// </summary>\n        /// <value>The services.</value>","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Engine/Engine/EntityManager.cs#L65-L101","documentation":"The protected EntityManager(IServiceRegistry) constructor throws ArgumentNullException when the registry argument is null, because the manager stores it as Services and needs it to resolve processors and other systems. It is raised before any entity bookkeeping is set up.","triggerScenarios":"Calling the constructor (from a derived class or via DI) passing null for the IServiceRegistry parameter.","commonSituations":"Manual instantiation of EntityManager in unit tests or custom game setups without a configured service registry; DI container missing a registration for IServiceRegistry.","solutions":["Pass a valid IServiceRegistry instance (e.g. the game's Services property)","Register IServiceRegistry in your DI container before constructing EntityManager","Add a null guard at the call site so construction is skipped until services exist"],"exampleFix":"// before\nvar entityManager = new MyEntityManager(null);\n// after\nvar entityManager = new MyEntityManager(game.Services);","handlingStrategy":"try-catch","validationCode":"if (registry == null) throw new InvalidOperationException(\"IServiceRegistry must be resolved before creating EntityManager\");","typeGuard":"static bool HasRegistry(IServiceRegistry r) => r != null;","tryCatchPattern":"try { var em = new MyEntityManager(registry); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"registry\") { /* resolve services first */ }","preventionTips":["Register IServiceRegistry in DI before constructing managers","In tests, build a minimal ServiceRegistry fixture","Pass game.Services rather than storing null placeholders"],"tags":["csharp","stride","argument-null","constructor"],"backgroundTag":"null-argument","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"}