{"record":{"id":"78f05180bac8ef35","repo":"PrismLibrary/Prism","slug":"resources-directorynotfound-string-format-with-modulepath-78f051","errorCode":null,"errorMessage":"Resources.DirectoryNotFound (string.Format with ModulePath)","messagePattern":"Resources\\.DirectoryNotFound \\(string\\.Format with ModulePath\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Wpf/Prism.Wpf/Modularity/DirectoryModuleCatalog.netcore.cs","lineNumber":39,"sourceCode":"    /// The directory catalog does not continue to monitor the directory after it has created the initialize 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 = 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                        && !String.IsNullOrEmpty(assembly.Location)\n                    select assembly.Location\n                );\n\n                loadedAssemblies.AddRange(assemblies);\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Wpf/Prism.Wpf/Modularity/DirectoryModuleCatalog.netcore.cs#L21-L57","documentation":"DirectoryModuleCatalog (.NET Core/.NET 5+ build) throws InvalidOperationException with the DirectoryNotFound resource formatted with ModulePath when the configured directory does not exist on disk. The message embeds the path, making the failing configuration explicit. Thrown in InnerLoad prior to scanning assemblies.","triggerScenarios":"ModulePath points to a nonexistent directory when Load() runs: wrong relative path, folder not published with the app, drive/UNC path unavailable in the deployment environment.","commonSituations":"Container/Linux deployments where a Windows-style path is invalid; the Modules folder missing from publish output; environment-specific paths (dev vs prod) not updated; working directory differences for hosted services.","solutions":["Ensure the directory exists before Load; create it with Directory.CreateDirectory if your app owns it.","Resolve with an absolute path: Path.Combine(AppContext.BaseDirectory, \"Modules\").","Fix publish settings so module assemblies/folder are copied to output.","Check casing and separators on case-sensitive file systems (Linux)."],"exampleFix":"// before\ncatalog.ModulePath = @\"C:\\App\\Modules\"; // invalid on Linux host\n\n// after\ncatalog.ModulePath = Path.Combine(AppContext.BaseDirectory, \"Modules\");","handlingStrategy":"validation","validationCode":"if (!Directory.Exists(catalog.ModulePath))\n    throw new DirectoryNotFoundException($\"Modules directory not found: {catalog.ModulePath}\");","typeGuard":"static bool ModulePathExists(string path) => !string.IsNullOrEmpty(path) && Directory.Exists(path);","tryCatchPattern":"try { catalog.Load(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(catalog.ModulePath)) { logger.LogError(ex, \"Modules directory missing: {Path}\", catalog.ModulePath); }","preventionTips":["Use Path.Combine(AppContext.BaseDirectory, \"Modules\") for OS-portable absolute paths.","Verify publish/copy-to-output includes the modules folder.","Check path casing on Linux hosts.","Create the directory at first run if the app owns it."],"tags":["directory","not-found","path","netcore"],"backgroundTag":"directory-not-found","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"}