{"record":{"id":"cd5c1179b57c5436","repo":"PrismLibrary/Prism","slug":"imodulecatalog-was-null","errorCode":null,"errorMessage":"IModuleCatalog was null","messagePattern":"IModuleCatalog was null","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/Avalonia/Prism.Avalonia/PrismBootstrapperBase.cs","lineNumber":109,"sourceCode":"        /// <summary>\n        /// Creates the <see cref=\"IModuleCatalog\"/> used by Prism.\n        /// </summary>\n        ///  <remarks>\n        /// The base implementation returns a new ModuleCatalog.\n        /// </remarks>\n        protected virtual IModuleCatalog CreateModuleCatalog()\n        {\n            return new ModuleCatalog();\n        }\n\n        /// <summary>\n        /// Registers all types that are required by Prism to function with the container.\n        /// </summary>\n        /// <param name=\"containerRegistry\"></param>\n        protected virtual void RegisterRequiredTypes(IContainerRegistry containerRegistry)\n        {\n            if (_moduleCatalog == null)\n                throw new InvalidOperationException(\"IModuleCatalog was null\");\n\n            containerRegistry.RegisterRequiredTypes(_moduleCatalog);\n        }\n\n        /// <summary>\n        /// Used to register types with the container that will be used by your application.\n        /// </summary>\n        protected abstract void RegisterTypes(IContainerRegistry containerRegistry);\n\n        /// <summary>\n        /// Configures the <see cref=\"IRegionBehaviorFactory\"/>.\n        /// This will be the list of default behaviors that will be added to a region.\n        /// </summary>\n        protected virtual void ConfigureDefaultRegionBehaviors(IRegionBehaviorFactory regionBehaviors)\n        {\n            regionBehaviors?.RegisterDefaultRegionBehaviors();\n        }\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Avalonia/Prism.Avalonia/PrismBootstrapperBase.cs#L91-L127","documentation":"PrismBootstrapperBase.RegisterRequiredTypes validates that the module catalog (_moduleCatalog) was created before registering required types with the DI container. If it is null, the app cannot function (no module metadata) and an InvalidOperationException is thrown during Initialize.","triggerScenarios":"Overriding CreateModuleCatalog (or the catalog setup path) and returning null, or overriding RegisterRequiredTypes/Initialize such that _moduleCatalog was never assigned, or a custom bootstrapper flow that skips catalog creation.","commonSituations":"Custom bootstrapper overrides that forget to call base methods; CreateModuleCatalog returning null by mistake; copy-pasted bootstrapper code from a different Prism version where catalog creation differs; module catalog configured conditionally and the condition never true.","solutions":["Ensure CreateModuleCatalog override returns a valid IModuleCatalog (e.g. new ModuleCatalog()).","Call base.CreateModuleCatalog()/base initialization steps when overriding bootstrapper methods.","If using ConfigureModuleCatalog, verify the base Initialize pipeline still runs to assign _moduleCatalog.","Check custom Initialize overrides don't skip RegisterRequiredTypes order."],"exampleFix":"// before\nprotected override IModuleCatalog CreateModuleCatalog() => null;\n// after\nprotected override IModuleCatalog CreateModuleCatalog() => new ModuleCatalog();","handlingStrategy":"validation","validationCode":"protected override IModuleCatalog CreateModuleCatalog()\n    => base.CreateModuleCatalog() ?? throw new InvalidOperationException(\"CreateModuleCatalog must not return null\");","typeGuard":"bool HasCatalog(IModuleCatalog? c) => c is not null;","tryCatchPattern":"try { bootstrapper.Initialize(); }\ncatch (InvalidOperationException ex) when (ex.Message == \"IModuleCatalog was null\") { /* check CreateModuleCatalog override */ }","preventionTips":["Always call base methods when overriding bootstrapper lifecycle methods","Return a concrete ModuleCatalog instance from CreateModuleCatalog","Add an integration test that boots the app shell"],"tags":["prism","bootstrapper","module-catalog","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}