PrismLibrary/Prism · error · ModuleNotFoundException
Module was not found in the catalog.
Error message
Module {0} was not found in the catalog. What it means
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.
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.
Example fix
// before
moduleManager.LoadModule("OrderModl"); // typo
// after
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
moduleCatalog.AddModule<OrderModule>(name: "OrderModule", InitializationMode.OnDemand);
}
moduleManager.LoadModule("OrderModule"); Defensive patterns
Strategy: validation
Validate before calling
var matches = moduleCatalog.Modules.Where(m => m.ModuleName == moduleName).ToList();
if (matches.Count == 0)
throw new InvalidOperationException($"Module '{moduleName}' not registered. Available: {string.Join(", ", moduleCatalog.Modules.Select(m => m.ModuleName))}");
moduleManager.LoadModule(moduleName); Try / catch
try
{
moduleManager.LoadModule(name);
}
catch (ModuleNotFoundException ex)
{
logger.LogError(ex, "Module {Module} missing from catalog", name);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- A duplicated module with name
- Value cannot be null. (Parameter 'name')
- Value cannot be null. (Parameter 'dependsOn')
- Value cannot be null. (Parameter 'type')
- Module Reference Location is not supported in Maui
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/63ddfee60b6c1dd5.
Report an issue: GitHub.
Appendix: source
Thrown at src/Maui/Prism.Maui/Modularity/ModuleManager.cs:68
/// <summary>
/// Initializes the modules marked as <see cref="InitializationMode.WhenAvailable"/> in the <see cref="ModuleCatalog"/>.
/// </summary>
public void Run()
{
LoadModulesWhenAvailable();
}
/// <summary>
/// Loads and initializes the module in the <see cref="IModuleCatalog"/> with the name <paramref name="moduleName"/>.
/// </summary>
/// <param name="moduleName">Name of the module requested for initialization.</param>
public void LoadModule(string moduleName)
{
var modules = ModuleCatalog.Modules.Where(m => m.ModuleName == moduleName);
if (modules == null || modules.Count() == 0)
{
throw new ModuleNotFoundException(moduleName, string.Format(CultureInfo.CurrentCulture, Resources.ModuleNotFound, moduleName));
}
else if (modules.Count() > 1)
{
throw new DuplicateModuleException(moduleName, string.Format(CultureInfo.CurrentCulture, Resources.DuplicatedModuleInCatalog, moduleName));
}
var modulesToLoad = ModuleCatalog.CompleteListWithDependencies(modules);
LoadModules(modulesToLoad);
}
/// <summary>
/// Loads the <see cref="IModule"/>'s with <see cref="InitializationMode.WhenAvailable"/>
/// </summary>
protected void LoadModulesWhenAvailable()
{
var whenAvailableModules = ModuleCatalog.Modules.Where(m => m.InitializationMode == InitializationMode.WhenAvailable && m.State == ModuleState.NotStarted);
if (whenAvailableModules != null)View on GitHub (pinned to 358118cd64)