{"record":{"id":"15af436b7b50d4ea","repo":"PrismLibrary/Prism","slug":"resources-modulepathcannotbenullorempty","errorCode":null,"errorMessage":"Resources.ModulePathCannotBeNullOrEmpty","messagePattern":"Resources\\.ModulePathCannotBeNullOrEmpty","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Wpf/Prism.Wpf/Modularity/DirectoryModuleCatalog.net45.cs","lineNumber":34,"sourceCode":"    /// Assemblies are loaded into a new application domain with ReflectionOnlyLoad.  The application domain is destroyed\n    /// once the assemblies have been discovered.\n    ///\n    /// The diretory catalog does not continue to monitor the directory after it has created the initialze catalog.\n    /// </remarks>\n    public class DirectoryModuleCatalog : ModuleCatalog\n    {\n        /// <summary>\n        /// Directory containing modules to search for.\n        /// </summary>\n        public string ModulePath { get; set; }\n\n        /// <summary>\n        /// Drives the main logic of building the child domain and searching for the assemblies.\n        /// </summary>\n        protected override void InnerLoad()\n        {\n            if (string.IsNullOrEmpty(ModulePath))\n                throw new InvalidOperationException(Resources.ModulePathCannotBeNullOrEmpty);\n\n            if (!Directory.Exists(ModulePath))\n                throw new InvalidOperationException(\n                    string.Format(CultureInfo.CurrentCulture, Resources.DirectoryNotFound, ModulePath));\n\n            AppDomain childDomain = BuildChildDomain(AppDomain.CurrentDomain);\n\n            try\n            {\n                List<string> loadedAssemblies = new List<string>();\n\n                var assemblies = (\n                                     from Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()\n                                     where !(assembly is System.Reflection.Emit.AssemblyBuilder)\n                                        && assembly.GetType().FullName != \"System.Reflection.Emit.InternalAssemblyBuilder\"\n                                        // TODO: Do this in a less hacky way... probably never gonna happen\n                                        && !assembly.GetName().Name.StartsWith(\"xunit\")\n                                        && !string.IsNullOrEmpty(assembly.Location)","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Wpf/Prism.Wpf/Modularity/DirectoryModuleCatalog.net45.cs#L16-L52","documentation":"DirectoryModuleCatalog (.NET Framework build) throws InvalidOperationException when ModulePath is null or empty. This catalog scans a directory on disk for assemblies containing modules, so a path is mandatory. The check happens first in InnerLoad before any directory scanning or child AppDomain creation.","triggerScenarios":"Creating a DirectoryModuleCatalog and calling Load() without setting the ModulePath property, or setting it to an empty string.","commonSituations":"Configuring directory-based module discovery but forgetting ModulePath; reading the path from config and the config key is empty/missing; refactoring moved the path assignment away from catalog creation.","solutions":["Set ModulePath to an existing directory containing your module assemblies before calling Load(): catalog.ModulePath = @\".\\Modules\";","If the path comes from configuration, ensure the config value is present and non-empty.","Add a startup assertion/log if ModulePath is resolved dynamically so misconfiguration is caught early.","Consider DirectoryModuleCatalog from the config-based setup only when directory scanning is actually needed."],"exampleFix":"// before\nvar catalog = new DirectoryModuleCatalog();\ncatalog.Load();\n\n// after\nvar catalog = new DirectoryModuleCatalog { ModulePath = @\".\\Modules\" };\ncatalog.Load();","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(catalog.ModulePath))\n    throw new InvalidOperationException(\"DirectoryModuleCatalog.ModulePath must be set before Load().\");","typeGuard":"static bool HasModulePath(DirectoryModuleCatalog c) => !string.IsNullOrEmpty(c.ModulePath);","tryCatchPattern":"try { catalog.Load(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"ModulePath\") || ex.Message.Contains(\"path\")) { logger.LogError(ex, \"ModulePath not configured\"); }","preventionTips":["Set ModulePath in the same place the catalog is created.","Read the path from config with a non-empty default.","Fail fast at startup when configured path is blank.","Add tests mirroring production catalog construction."],"tags":["directory","modularity","path","wpf"],"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"}