{"record":{"id":"63ddfee60b6c1dd5","repo":"PrismLibrary/Prism","slug":"module-0-was-not-found-in-the-catalog","errorCode":null,"errorMessage":"Module {0} was not found in the catalog.","messagePattern":"Module (.+?) was not found in the catalog\\.","errorType":"exception","errorClass":"ModuleNotFoundException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Modularity/ModuleManager.cs","lineNumber":68,"sourceCode":"\n    /// <summary>\n    /// Initializes the modules marked as <see cref=\"InitializationMode.WhenAvailable\"/> in the <see cref=\"ModuleCatalog\"/>.\n    /// </summary>\n    public void Run()\n    {\n        LoadModulesWhenAvailable();\n    }\n\n    /// <summary>\n    /// Loads and initializes the module in the <see cref=\"IModuleCatalog\"/> with the name <paramref name=\"moduleName\"/>.\n    /// </summary>\n    /// <param name=\"moduleName\">Name of the module requested for initialization.</param>\n    public void LoadModule(string moduleName)\n    {\n        var modules = ModuleCatalog.Modules.Where(m => m.ModuleName == moduleName);\n        if (modules == null || modules.Count() == 0)\n        {\n            throw new ModuleNotFoundException(moduleName, string.Format(CultureInfo.CurrentCulture, Resources.ModuleNotFound, moduleName));\n        }\n        else if (modules.Count() > 1)\n        {\n            throw new DuplicateModuleException(moduleName, string.Format(CultureInfo.CurrentCulture, Resources.DuplicatedModuleInCatalog, moduleName));\n        }\n\n        var modulesToLoad = ModuleCatalog.CompleteListWithDependencies(modules);\n\n        LoadModules(modulesToLoad);\n    }\n\n    /// <summary>\n    /// Loads the <see cref=\"IModule\"/>'s with <see cref=\"InitializationMode.WhenAvailable\"/>\n    /// </summary>\n    protected void LoadModulesWhenAvailable()\n    {\n        var whenAvailableModules = ModuleCatalog.Modules.Where(m => m.InitializationMode == InitializationMode.WhenAvailable && m.State == ModuleState.NotStarted);\n        if (whenAvailableModules != null)","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Modularity/ModuleManager.cs#L50-L86","documentation":"LoadModule(moduleName) looks up modules in the IModuleCatalog by ModuleName. When no module matches the requested name, it throws ModuleNotFoundException wrapping the 'Module {0} was not found in the catalog.' message. Prism throws this so on-demand module initialization fails loudly instead of silently doing nothing.","triggerScenarios":"Calling moduleManager.LoadModule(\"MyModule\") (directly or via IModuleManager) where no IModuleInfo in the catalog has ModuleName == \"MyModule\", typically due to a typo or the module never being added to the catalog.","commonSituations":"Module registered with a different name string than used in LoadModule; ConfigureModuleCatalog never called or AddModule skipped for that module; rename of the module class without updating the name string; case-sensitivity mismatch.","solutions":["Add the module to the catalog in ConfigureModuleCatalog: catalog.AddModule<MyModule>(name: \"MyModule\", initializationMode: InitializationMode.OnDemand).","Verify the ModuleName string passed to LoadModule exactly matches the registered name (watch casing and whitespace).","Before calling, validate with ModuleCatalog.Modules.Any(m => m.ModuleName == name) and log available names if false."],"exampleFix":"// before\nmoduleManager.LoadModule(\"OrderModl\"); // typo\n// after\nprotected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)\n{\n    moduleCatalog.AddModule<OrderModule>(name: \"OrderModule\", InitializationMode.OnDemand);\n}\nmoduleManager.LoadModule(\"OrderModule\");","handlingStrategy":"validation","validationCode":"var matches = moduleCatalog.Modules.Where(m => m.ModuleName == moduleName).ToList();\nif (matches.Count == 0)\n    throw new InvalidOperationException($\"Module '{moduleName}' not registered. Available: {string.Join(\", \", moduleCatalog.Modules.Select(m => m.ModuleName))}\");\nmoduleManager.LoadModule(moduleName);","typeGuard":null,"tryCatchPattern":"try\n{\n    moduleManager.LoadModule(name);\n}\ncatch (ModuleNotFoundException ex)\n{\n    logger.LogError(ex, \"Module {Module} missing from catalog\", name);\n}","preventionTips":["Define module names as string constants shared between registration and LoadModule calls.","Populate the catalog in one ConfigureModuleCatalog override only.","Log all catalog module names at startup for diagnostics."],"tags":["module-not-found","modularity","catalog"],"backgroundTag":"entity-not-found","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"}