{"record":{"id":"568008cb4f14a749","repo":"PrismLibrary/Prism","slug":"resources-invalidargumentassemblyuri","errorCode":null,"errorMessage":"Resources.InvalidArgumentAssemblyUri","messagePattern":"Resources\\.InvalidArgumentAssemblyUri","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Wpf/Prism.Wpf/Modularity/AssemblyResolver.Desktop.cs","lineNumber":35,"sourceCode":"        /// <summary>\n        /// Registers the specified assembly and resolves the types in it when the AppDomain requests for it.\n        /// </summary>\n        /// <param name=\"assemblyFilePath\">The path to the assembly to load in the LoadFrom context.</param>\n        /// <remarks>This method does not load the assembly immediately, but lazily until someone requests a <see cref=\"Type\"/>\n        /// declared in the assembly.</remarks>\n        public void LoadAssemblyFrom(string assemblyFilePath)\n        {\n            if (!_handlesAssemblyResolve)\n            {\n                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;\n                _handlesAssemblyResolve = true;\n            }\n\n            Uri assemblyUri = GetFileUri(assemblyFilePath);\n\n            if (assemblyUri == null)\n            {\n                throw new ArgumentException(Resources.InvalidArgumentAssemblyUri, nameof(assemblyFilePath));\n            }\n\n            if (!File.Exists(assemblyUri.LocalPath))\n            {\n                throw new FileNotFoundException(null, assemblyUri.LocalPath);\n            }\n\n            AssemblyName assemblyName = AssemblyName.GetAssemblyName(assemblyUri.LocalPath);\n            AssemblyInfo assemblyInfo = registeredAssemblies.FirstOrDefault(a => assemblyName == a.AssemblyName);\n\n            if (assemblyInfo != null)\n            {\n                return;\n            }\n\n            assemblyInfo = new AssemblyInfo() { AssemblyName = assemblyName, AssemblyUri = assemblyUri };\n            registeredAssemblies.Add(assemblyInfo);\n        }","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Wpf/Prism.Wpf/Modularity/AssemblyResolver.Desktop.cs#L17-L53","documentation":"AssemblyResolver.LoadAssemblyFrom throws ArgumentException when the assembly path cannot be converted into a valid file URI by GetFileUri. Prism validates the path before attempting to load the assembly, because a malformed path would otherwise produce confusing loader exceptions deep inside the CLR. The message is the resource string Resources.InvalidArgumentAssemblyUri and the parameter name (assemblyFilePath) is attached via nameof.","triggerScenarios":"Calling ModuleCatalog.LoadModule (or AssemblyResolver.LoadAssemblyFrom directly) with a null, empty, or malformed assembly path string that GetFileUri cannot turn into a Uri; e.g. passing a module Ref like 'file://foo' with illegal characters or a relative garbage path.","commonSituations":"A module entry in a Prism configuration file (modules config section) has a bad assembly='...' ref; a partial assembly name string is passed instead of a path/URI; whitespace or invalid URI characters in the path; unit tests exercising invalid-file-path behavior.","solutions":["Check the assemblyFilePath/Ref value passed to LoadAssemblyFrom; ensure it is a valid absolute or relative file path with no illegal URI characters.","Use a proper file path like 'Modules\\MyModule.dll' or a file:// URI, and verify File.Exists on the resolved path before loading.","If configuring via app.config, fix the assembly attribute of the module entry to point to the real DLL location.","Wrap LoadAssemblyFrom in a try/catch for ArgumentException and log the offending path to identify the bad config entry."],"exampleFix":"// before\ncatalog.AddModule(typeof(MyModule), \"MyModule,,bad uri<>\", true);\n\n// after\ncatalog.AddModule(typeof(MyModule), \"Modules\\\\MyModule.dll\", \"MyModule\", true);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(assemblyFilePath) || Uri.TryCreate(assemblyFilePath, UriKind.Absolute, out var uri) == false)\n    throw new ArgumentException($\"Invalid assembly path: '{assemblyFilePath}'\", nameof(assemblyFilePath));","typeGuard":"static bool IsValidAssemblyPath(string path) => !string.IsNullOrWhiteSpace(path) && GetFileUri(path) != null;","tryCatchPattern":"try { resolver.LoadAssemblyFrom(path); }\ncatch (ArgumentException ex) { logger.LogError(ex, \"Invalid assembly path: {Path}\", path); }","preventionTips":["Always pass absolute file paths or valid file:// URIs for module assemblies.","Validate module Ref values from configuration at startup.","Keep paths free of illegal URI characters.","Add a startup check that every configured module path exists."],"tags":["argument","uri","modularity","wpf"],"backgroundTag":"invalid-url-format","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"}