{"record":{"id":"a4ed00110fd9d4d2","repo":"PrismLibrary/Prism","slug":"resources-stringcannotbenullorempty-formatted-with-name","errorCode":null,"errorMessage":"Resources.StringCannotBeNullOrEmpty (formatted with 'name')","messagePattern":"Resources\\.StringCannotBeNullOrEmpty \\(formatted with 'name'\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Prism.Core/Modularity/ModuleDependencySolver.cs","lineNumber":25,"sourceCode":"namespace Prism.Modularity\n{\n    /// <summary>\n    /// Used by <see cref=\"IModuleInitializer\"/> to get the load sequence\n    /// for the modules to load according to their dependencies.\n    /// </summary>\n    public class ModuleDependencySolver\n    {\n        private readonly ListDictionary<string, string> dependencyMatrix = new ListDictionary<string, string>();\n        private readonly List<string> knownModules = new List<string>();\n\n        /// <summary>\n        /// Adds a module to the solver.\n        /// </summary>\n        /// <param name=\"name\">The name that uniquely identifies the module.</param>\n        public void AddModule(string name)\n        {\n            if (String.IsNullOrEmpty(name))\n                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, \"name\"));\n\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))","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Prism.Core/Modularity/ModuleDependencySolver.cs#L7-L43","documentation":"ModuleDependencySolver.AddModule throws ArgumentException with Resources.StringCannotBeNullOrEmpty when the module name is null or empty. Module names are the solver's identity keys for ordering and cycle detection, so a null/empty name is rejected immediately.","triggerScenarios":"Calling solver.AddModule(null) or AddModule(\"\") directly, or indirectly when SolveDependencies iterates a catalog containing an IModuleInfo whose ModuleName is null or empty.","commonSituations":"Programmatically created ModuleInfo objects with the name forgotten; config/XAML entries missing the module name attribute; data binding that produced an empty name.","solutions":["Set a non-empty ModuleName on every IModuleInfo added to the catalog.","Check the module definition source (code, XAML, app.config) for a missing name attribute.","Add a pre-validation pass that rejects modules with string.IsNullOrWhiteSpace(ModuleName)."],"exampleFix":"// before\nvar module = new ModuleInfo { ModuleType = typeof(MyModule).AssemblyQualifiedName }; // ModuleName empty\n// after\nvar module = new ModuleInfo { ModuleName = \"MyModule\", ModuleType = typeof(MyModule).AssemblyQualifiedName };","handlingStrategy":"validation","validationCode":"if (modules.Any(m => string.IsNullOrWhiteSpace(m.ModuleName)))\n    throw new InvalidOperationException(\"All modules must have a non-empty ModuleName before catalog validation\");","typeGuard":"bool HasName(IModuleInfo m) => !string.IsNullOrWhiteSpace(m?.ModuleName);","tryCatchPattern":"try\n{\n    catalog.Validate();\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"name\"))\n{\n    logger.LogError(ex, \"A module with an empty ModuleName reached the dependency solver\");\n}","preventionTips":["Always set ModuleName when constructing ModuleInfo","Validate module definitions parsed from config/XAML for a name attribute","Filter or reject modules with whitespace-only names early"],"tags":["argument","empty-string","dependency-solver","prism"],"backgroundTag":"empty-required-field","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"}