{"record":{"id":"153fdc293225db04","repo":"PrismLibrary/Prism","slug":"resources-stringcannotbenullorempty-formatted-with-153fdc","errorCode":null,"errorMessage":"Resources.StringCannotBeNullOrEmpty (formatted with 'dependentModule')","messagePattern":"Resources\\.StringCannotBeNullOrEmpty \\(formatted with 'dependentModule'\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Prism.Core/Modularity/ModuleDependencySolver.cs","lineNumber":44,"sourceCode":"\n            AddToDependencyMatrix(name);\n            AddToKnownModules(name);\n        }\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        {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Prism.Core/Modularity/ModuleDependencySolver.cs#L26-L62","documentation":"This ArgumentException is thrown by ModuleDependencySolver.AddDependency when the 'dependentModule' argument is null or an empty string. Prism validates both module-name parameters before registering a dependency edge, because an empty edge would corrupt the dependency matrix used to compute the module load order.","triggerScenarios":"Calling AddDependency(dependingModule, dependentModule) with a null or \"\" dependentModule — e.g. reading ModuleInfo.ModuleName from a catalog entry whose Name was never set, or wiring dependencies programmatically before names are assigned.","commonSituations":"Module catalog entries declared in app.config/XAML with a missing ModuleName attribute; refactoring code that renamed a module constant to null; building catalogs dynamically from a data source that returns blank names.","solutions":["Ensure the dependent module's ModuleName is set and non-empty before calling AddDependency","Guard each dependency registration with String.IsNullOrWhiteSpace checks and skip or fix the bad entry","If building from config, fix the module declaration so ModuleName is present"],"exampleFix":"// before\nsolver.AddDependency(\"ModuleA\", moduleInfo.ModuleName); // ModuleName is \"\"\n// after\nif (!string.IsNullOrWhiteSpace(moduleInfo.ModuleName))\n    solver.AddDependency(\"ModuleA\", moduleInfo.ModuleName);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(dependentModule))\n    throw new InvalidOperationException(\"dependentModule name must be non-empty before AddDependency\");","typeGuard":"bool IsValidModuleName(string? name) => !string.IsNullOrWhiteSpace(name);","tryCatchPattern":"try\n{\n    solver.AddDependency(depending, dependent);\n}\ncatch (ArgumentException ex) when (ex.ParamName == \"dependentModule\")\n{\n    logger.LogError(ex, \"Empty dependent module name\");\n}","preventionTips":["Always set ModuleName on ModuleInfo before registering dependencies","Validate names when building catalogs from config","Prefer nameof or constants for module names"],"tags":["argumentexception","null-or-empty","modularity","prism"],"backgroundTag":"null-argument","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"}