PrismLibrary/Prism · error · ArgumentException

Resources.InvalidArgumentAssemblyUri

Error message

Resources.InvalidArgumentAssemblyUri

What it means

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.

Solutions

  1. Check the assemblyFilePath/Ref value passed to LoadAssemblyFrom; ensure it is a valid absolute or relative file path with no illegal URI characters.
  2. Use a proper file path like 'Modules\MyModule.dll' or a file:// URI, and verify File.Exists on the resolved path before loading.
  3. If configuring via app.config, fix the assembly attribute of the module entry to point to the real DLL location.
  4. Wrap LoadAssemblyFrom in a try/catch for ArgumentException and log the offending path to identify the bad config entry.

Example fix

// before
catalog.AddModule(typeof(MyModule), "MyModule,,bad uri<>", true);

// after
catalog.AddModule(typeof(MyModule), "Modules\\MyModule.dll", "MyModule", true);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(assemblyFilePath) || Uri.TryCreate(assemblyFilePath, UriKind.Absolute, out var uri) == false)
    throw new ArgumentException($"Invalid assembly path: '{assemblyFilePath}'", nameof(assemblyFilePath));

Type guard

static bool IsValidAssemblyPath(string path) => !string.IsNullOrWhiteSpace(path) && GetFileUri(path) != null;

Try / catch

try { resolver.LoadAssemblyFrom(path); }
catch (ArgumentException ex) { logger.LogError(ex, "Invalid assembly path: {Path}", path); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15). Data as JSON: /api/errors/568008cb4f14a749. Report an issue: GitHub.

Appendix: source

Thrown at src/Wpf/Prism.Wpf/Modularity/AssemblyResolver.Desktop.cs:35

        /// <summary>
        /// Registers the specified assembly and resolves the types in it when the AppDomain requests for it.
        /// </summary>
        /// <param name="assemblyFilePath">The path to the assembly to load in the LoadFrom context.</param>
        /// <remarks>This method does not load the assembly immediately, but lazily until someone requests a <see cref="Type"/>
        /// declared in the assembly.</remarks>
        public void LoadAssemblyFrom(string assemblyFilePath)
        {
            if (!_handlesAssemblyResolve)
            {
                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
                _handlesAssemblyResolve = true;
            }

            Uri assemblyUri = GetFileUri(assemblyFilePath);

            if (assemblyUri == null)
            {
                throw new ArgumentException(Resources.InvalidArgumentAssemblyUri, nameof(assemblyFilePath));
            }

            if (!File.Exists(assemblyUri.LocalPath))
            {
                throw new FileNotFoundException(null, assemblyUri.LocalPath);
            }

            AssemblyName assemblyName = AssemblyName.GetAssemblyName(assemblyUri.LocalPath);
            AssemblyInfo assemblyInfo = registeredAssemblies.FirstOrDefault(a => assemblyName == a.AssemblyName);

            if (assemblyInfo != null)
            {
                return;
            }

            assemblyInfo = new AssemblyInfo() { AssemblyName = assemblyName, AssemblyUri = assemblyUri };
            registeredAssemblies.Add(assemblyInfo);
        }

View on GitHub (pinned to 358118cd64)