{"record":{"id":"77e723c5203b6a1d","repo":"PrismLibrary/Prism","slug":"an-error-was-encountered-while-configuring-the-module","errorCode":null,"errorMessage":"An error was encountered while configuring the Module Catalog","messagePattern":"An error was encountered while configuring the Module Catalog","errorType":"exception","errorClass":"PrismInitializationException","httpStatus":null,"severity":"critical","filePath":"src/Maui/Prism.Maui/PrismAppBuilder.cs","lineNumber":208,"sourceCode":"        var errors = new List<Exception>();\n\n        // Phase 1: Configure the module catalog\n        _moduleCatalogActions.ForEach(action =>\n        {\n            try\n            {\n                action(_container);\n            }\n            catch (Exception ex)\n            {\n                logger.LogError(ex, \"Error executing Module Catalog Configuration Delegate.\");\n                errors.Add(ex);\n            }\n        });\n\n        if (errors.Count == 1)\n        {\n            throw new PrismInitializationException(\"An error was encountered while configuring the Module Catalog\", errors[0]);\n        }\n        else if (errors.Count > 1)\n        {\n            throw new AggregateException(\"One or more errors were encountered while configuring the Module Catalog\", [.. errors]);\n        }\n\n        // Phase 2: Initialize modules so their services are registered\n        if (_container.IsRegistered<IModuleCatalog>() && _container.Resolve<IModuleCatalog>().Modules.Any())\n        {\n            try\n            {\n                logger.LogDebug(\"Initializing modules.\");\n                var manager = _container.Resolve<IModuleManager>();\n                manager.Run();\n                logger.LogDebug(\"Modules Initialized.\");\n            }\n            catch (Exception ex)\n            {","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/PrismAppBuilder.cs#L190-L226","documentation":"During app initialization Prism runs all IModuleCatalog configuration delegates and collects exceptions. If exactly one module catalog error occurs, it is rethrown as a PrismInitializationException with this message. It signals that module discovery/registration failed at startup.","triggerScenarios":"Calling UsePrism with OnInitialized/ConfigureModuleCatalog code that throws for a single module — e.g. AddModule for an assembly or type that cannot be loaded, or a module's RegisterTypes throwing during catalog configuration.","commonSituations":"Referencing a module assembly missing from the app package; a module type renamed/moved after refactor; single module failing to initialize its catalog entries on MAUI startup.","solutions":["Inspect InnerException of the PrismInitializationException for the module that failed.","Verify the failing module's assembly is included in the app and the module type is public with a valid constructor.","Fix or remove the AddModule/ConfigureModuleCatalog registration for the broken module.","If multiple modules fail you would instead see an AggregateException; isolate by disabling modules one at a time."],"exampleFix":"// before\nmoduleCatalog.AddModule<BillingModule>(); // assembly not referenced\n// after: ensure the project references the Billing module assembly, then\nmoduleCatalog.AddModule<BillingModule>(InitializationMode.WhenAvailable);","handlingStrategy":"validation","validationCode":"// Validate module types are loadable before registering\nvar t = typeof(BillingModule);\nif (t.IsClass && !t.IsAbstract && Assembly.GetAssembly(t) != null)\n    moduleCatalog.AddModule(t);","typeGuard":null,"tryCatchPattern":"try\n{\n    await host.StartAsync();\n}\ncatch (PrismInitializationException ex)\n{\n    logger.LogError(ex.InnerException, \"Module catalog configuration failed\");\n}","preventionTips":["Reference all module assemblies in the head app project.","Keep module types public with parameterless-friendly constructors.","Run a CI build that loads the full module catalog before release."],"tags":["dotnet","maui","prism","modules","startup"],"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"}