PrismLibrary/Prism · error · ModularityException

Resources.DependencyOnMissingModule (formatted with…

Error message

Resources.DependencyOnMissingModule (formatted with moduleNames)

What it means

This ModularityException is thrown by ModuleDependencySolver.Solve when a module in the graph depends on a module that was never registered with AddModule. The message lists the missing module names, produced by FindMissingModules.

Solutions

  1. Add the missing module to the catalog/solver with AddModule before solving
  2. Remove the stale dependency from the depending module's declaration
  3. Check the exception message (it contains the missing names) and align the spellings exactly

Example fix

// before
// ModuleInfo for "CoreModule" missing from catalog, but:
[Module(ModuleName="FeatureA", DependsOn=new[]{"CoreModule"})]
// after
// ensure CoreModule's ModuleInfo is added to the ModuleCatalog
Defensive patterns

Strategy: try-catch

Validate before calling

var missing = deps.Keys
    .SelectMany(k => deps[k])
    .Where(dep => !knownModules.Contains(dep))
    .ToList();
if (missing.Count > 0)
    throw new InvalidOperationException($"Missing modules: {string.Join(",", missing)}");

Try / catch

try
{
    var order = solver.Solve();
}
catch (ModularityException ex)
{
    logger.LogError(ex, "Modules depend on missing modules: {0}", ex.Message);
}

Prevention

When it happens

Trigger: Calling AddDependency("A", "B") where "B" is not in knownModules — e.g. a module in config lists a dependency on a module not present in the catalog; case mismatch between the two name usages.

Common situations: Removing a module from the catalog while other modules still declare a dependency on it; renaming a module but forgetting to update consumers' DependsOn attributes; loading a partial module set in tests.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15). Data as JSON: /api/errors/e28ea65d3bab42a1. Report an issue: GitHub.

Appendix: source

Thrown at src/Prism.Core/Modularity/ModuleDependencySolver.cs:93

        /// when a cycle is found in the defined dependency graph.</exception>
        public string[] Solve()
        {
            List<string> skip = new List<string>();
            while (skip.Count < dependencyMatrix.Count)
            {
                List<string> leaves = this.FindLeaves(skip);
                if (leaves.Count == 0 && skip.Count < dependencyMatrix.Count)
                {
                    throw new CyclicDependencyFoundException(Resources.CyclicDependencyFound);
                }
                skip.AddRange(leaves);
            }
            skip.Reverse();

            if (skip.Count > knownModules.Count)
            {
                string moduleNames = this.FindMissingModules(skip);
                throw new ModularityException(moduleNames, string.Format(CultureInfo.CurrentCulture,
                                                            Resources.DependencyOnMissingModule,
                                                            moduleNames));
            }

            return skip.ToArray();
        }

        private string FindMissingModules(List<string> skip)
        {
            string missingModules = "";

            foreach (string module in skip)
            {
                if (!knownModules.Contains(module))
                {
                    missingModules += ", ";
                    missingModules += module;
                }

View on GitHub (pinned to 358118cd64)