{"record":{"id":"78c354f391c345c8","repo":"PrismLibrary/Prism","slug":"resources-dependencyforunknownmodule-formatted-with","errorCode":null,"errorMessage":"Resources.DependencyForUnknownModule (formatted with dependingModule)","messagePattern":"Resources\\.DependencyForUnknownModule \\(formatted with dependingModule\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Prism.Core/Modularity/ModuleDependencySolver.cs","lineNumber":47,"sourceCode":"        }\n\n        /// <summary>\n        /// Adds a module dependency between the modules specified by dependingModule and\n        /// dependentModule.\n        /// </summary>\n        /// <param name=\"dependingModule\">The name of the module with the dependency.</param>\n        /// <param name=\"dependentModule\">The name of the module dependingModule\n        /// depends on.</param>\n        public void AddDependency(string dependingModule, string dependentModule)\n        {\n            if (String.IsNullOrEmpty(dependingModule))\n                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, \"dependingModule\"));\n\n            if (String.IsNullOrEmpty(dependentModule))\n                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, \"dependentModule\"));\n\n            if (!knownModules.Contains(dependingModule))\n                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.DependencyForUnknownModule, dependingModule));\n\n            AddToDependencyMatrix(dependentModule);\n            dependencyMatrix.Add(dependentModule, dependingModule);\n        }\n\n        private void AddToDependencyMatrix(string module)\n        {\n            if (!dependencyMatrix.ContainsKey(module))\n            {\n                dependencyMatrix.Add(module);\n            }\n        }\n\n        private void AddToKnownModules(string module)\n        {\n            if (!knownModules.Contains(module))\n            {\n                knownModules.Add(module);","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Prism.Core/Modularity/ModuleDependencySolver.cs#L29-L65","documentation":"This ArgumentException is thrown when AddDependency is called with a 'dependingModule' that has never been added to the solver via AddModule. The solver only allows declaring dependencies between modules it already knows about, preventing edges pointing at unknown nodes.","triggerScenarios":"Calling AddDependency(\"ModuleA\", \"ModuleB\") where \"ModuleA\" was never registered with AddModule(\"ModuleA\") first; a typo in the module name; adding dependencies before populating the known module list.","commonSituations":"Registering modules in a loop but wiring dependencies in a separate pass where a name was mistyped; a module removed from the catalog while its consumers still reference it; ordering bugs where dependencies are added before modules.","solutions":["Call AddModule(dependingModule) for every module before calling AddDependency","Verify the depending module name matches exactly the name passed to AddModule (case-sensitive)","Reorder initialization: populate all known modules first, then add dependency edges"],"exampleFix":"// before\nsolver.AddDependency(\"ModuleA\", \"ModuleB\"); // ModuleA never added\n// after\nsolver.AddModule(\"ModuleA\");\nsolver.AddModule(\"ModuleB\");\nsolver.AddDependency(\"ModuleA\", \"ModuleB\");","handlingStrategy":"validation","validationCode":"foreach (var dep in dependencies)\n    if (!knownModules.Contains(dep.Dependant))\n        throw new InvalidOperationException($\"{dep.Dependant} must be added via AddModule first\");","typeGuard":"bool IsKnownModule(ModuleDependencySolver s, string name) => s.KnownModules.Contains(name);","tryCatchPattern":"try\n{\n    solver.AddDependency(depending, dependent);\n}\ncatch (ArgumentException ex) when (ex.ParamName == null)\n{\n    // DependencyForUnknownModule path\n    logger.LogError(ex, \"Unknown module {0}\", depending);\n}","preventionTips":["Register all modules before wiring any dependencies","Build names from a single source of truth (catalog), not string literals","Add a unit test that solves the graph to catch missing registrations early"],"tags":["argumentexception","unknown-module","modularity","prism"],"backgroundTag":"missing-dependency","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"}