{"record":{"id":"f7580aaf0833b406","repo":"PrismLibrary/Prism","slug":"imodulecatalog","errorCode":null,"errorMessage":"IModuleCatalog","messagePattern":"IModuleCatalog","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/Wpf/Prism.Wpf/PrismBootstrapperBase.cs","lineNumber":105,"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\");\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":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Wpf/Prism.Wpf/PrismBootstrapperBase.cs#L87-L123","documentation":"Prism's PrismBootstrapperBase.RegisterRequiredTypes throws this InvalidOperationException when the module catalog (_moduleCatalog) is null at the point where required types are registered with the DI container. Prism requires an IModuleCatalog instance to function (it drives module discovery/loading), so a null catalog is an unrecoverable application configuration error. The message is just the type name 'IModuleCatalog', so it looks cryptic but means 'you never provided a module catalog to the bootstrapper'.","triggerScenarios":"Calling base.RegisterRequiredTypes (indirectly via Run/ConfigureViewModelLocator startup flow) when the CreateModuleCatalog() override was not implemented, returned null, or the _moduleCatalog field was never assigned before registration runs.","commonSituations":"1) Developer overrides RegisterRequiredTypes or CreateModuleCatalog incorrectly or forgets to call base in a custom bootstrapper. 2) Upgrading Prism versions (Prism 8+ unified bootstrappers) where a custom bootstrapper no longer sets the catalog the old way. 3) Copying a bootstrapper template and deleting CreateModuleCatalog because the app 'doesn't use modules'. 4) Constructing PrismBootstrapperBase-derived class manually and calling Run before initialization populated _moduleCatalog.","solutions":["Override CreateModuleCatalog() in your bootstrapper and return a catalog instance (e.g. return new ModuleCatalog(); or ConfigureModuleCatalog variant for directory/xaml catalogs).","If you override RegisterRequiredTypes, ensure _moduleCatalog is set (call CreateModuleCatalog or assign the field) before calling base.RegisterRequiredTypes(containerRegistry).","Check the order of operations: Run() must complete CreateModuleCatalog/ConfigureModuleCatalog before RegisterRequiredTypes is invoked; do not call Run twice or call RegisterRequiredTypes manually early.","On Prism version upgrades, migrate to the current bootstrapper base (PrismBootstrapper) and let it create the default ModuleCatalog instead of a hand-rolled one."],"exampleFix":"// before\npublic class AppBootstrapper : PrismBootstrapperBase\n{\n    protected override void RegisterRequiredTypes(IContainerRegistry containerRegistry)\n    {\n        // base call throws: _moduleCatalog is null\n        base.RegisterRequiredTypes(containerRegistry);\n    }\n}\n// after\npublic class AppBootstrapper : PrismBootstrapperBase\n{\n    protected override IModuleCatalog CreateModuleCatalog()\n    {\n        return new ModuleCatalog(); // or a directory/XAML catalog\n    }\n}","handlingStrategy":"validation","validationCode":"// In a custom bootstrapper, before startup:\nprotected override IModuleCatalog CreateModuleCatalog()\n{\n    var catalog = new ModuleCatalog();\n    if (catalog == null) throw new InvalidOperationException(\n        \"CreateModuleCatalog must return a non-null IModuleCatalog instance.\");\n    return catalog;\n}","typeGuard":"bool HasModuleCatalog(PrismBootstrapperBase b, Func<IModuleCatalog> accessor)\n    => accessor?.Invoke() is IModuleCatalog; // false when null/missing","tryCatchPattern":"try\n{\n    bootstrapper.Run();\n}\ncatch (InvalidOperationException ex) when (ex.Message == \"IModuleCatalog\")\n{\n    // log: bootstrapper was not configured with a module catalog\n    // fix configuration: implement CreateModuleCatalog()\n}","preventionTips":["Always implement CreateModuleCatalog() in bootstrappers derived from PrismBootstrapperBase, even for module-free apps (return new ModuleCatalog()).","Call base.RegisterRequiredTypes() first in any RegisterRequiredTypes override so invariants are checked before your registrations.","When overriding CreateModuleCatalog, never return null; return an empty ModuleCatalog instead.","After upgrading Prism, run the app at least once in a smoke test before refactoring bootstrapper internals.","Prefer the newer PrismBootstrapper/PrismApplication base classes which auto-create the catalog, over hand-rolled bootstrappers."],"tags":["prism","wpf","dependency-injection","bootstrapper","null-reference","modules"],"backgroundTag":"null-argument","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"}