PrismLibrary/Prism · error · ModuleTypeLoaderNotFoundException

Resources.NoRetrieverCanRetrieveModule

Error message

Resources.NoRetrieverCanRetrieveModule

What it means

ModuleManager.GetTypeLoaderForModule iterates the registered IModuleTypeLoader instances and returns the first whose CanLoadModuleType(moduleInfo) is true. When no loader can handle the module's type, it throws ModuleTypeLoaderNotFoundException with Resources.NoRetrieverCanRetrieveModule. This indicates the ModuleInfo's Ref/Type is not supported by any configured loader (e.g., Xap loader missing in Silverlight scenarios, or an invalid Ref scheme).

Solutions

  1. Check ModuleInfo.Ref for each catalog entry and ensure it uses a scheme supported by the registered type loaders (typically an assembly path/URI).
  2. Register additional IModuleTypeLoader instances with the ModuleManager if you need to load modules from remote/other sources.
  3. Verify the module assembly file exists at the Ref path on disk/deployment.
  4. Use ConfigurationModuleCatalog/DirectoryModuleCatalog defaults instead of hand-rolled Refs when possible.

Example fix

// before
new ModuleInfo { ModuleName = "Foo", Ref = "ftp://server/Foo.dll", ModuleType = ... };
// after
new ModuleInfo { ModuleName = "Foo", Ref = @"file:@""Modules\\Foo.dll""", ModuleType = ... };
Defensive patterns

Strategy: try-catch

Validate before calling

foreach (var m in moduleCatalog.Modules)
{
    if (string.IsNullOrWhiteSpace(m.Ref) || !File.Exists(m.Ref))
        logger.LogWarning("Module {0} has missing/invalid Ref: {1}", m.ModuleName, m.Ref);
}

Try / catch

try
{
    moduleManager.Run();
}
catch (ModuleTypeLoaderNotFoundException ex)
{
    logger.LogError(ex, "No type loader can load module '{0}' — check Ref and registered loaders", ex.Message);
}

Prevention

When it happens

Trigger: LoadModuleTypes -> moduleTypeLoader for a ModuleInfo whose Ref does not match any type loader's CanLoadModuleType (e.g., a file:// or http Ref with only the static reference loader registered, or null/invalid Ref).

Common situations: On-demand download scenarios where the expected remote loader is not registered with the module manager; ModuleInfo.Ref strings with unsupported URI schemes; custom module formats added to the catalog without registering a corresponding IModuleTypeLoader.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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

Appendix: source

Thrown at src/Wpf/Prism.Wpf/Modularity/ModuleManager.cs:270

            }

            int notReadyRequiredModuleCount =
                requiredModules.Count(requiredModule => requiredModule.State != ModuleState.Initialized);

            return notReadyRequiredModuleCount == 0;
        }

        private IModuleTypeLoader GetTypeLoaderForModule(IModuleInfo moduleInfo)
        {
            foreach (IModuleTypeLoader typeLoader in ModuleTypeLoaders)
            {
                if (typeLoader.CanLoadModuleType(moduleInfo))
                {
                    return typeLoader;
                }
            }

            throw new ModuleTypeLoaderNotFoundException(moduleInfo.ModuleName, string.Format(CultureInfo.CurrentCulture, Resources.NoRetrieverCanRetrieveModule, moduleInfo.ModuleName), null);
        }

        private void InitializeModule(IModuleInfo moduleInfo)
        {
            if (moduleInfo.State == ModuleState.Initializing)
            {
                moduleInitializer.Initialize(moduleInfo);
                moduleInfo.State = ModuleState.Initialized;
                RaiseLoadModuleCompleted(moduleInfo, null);
            }
        }

        #region Implementation of IDisposable

        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        /// <remarks>Calls <see cref="Dispose(bool)"/></remarks>.

View on GitHub (pinned to 358118cd64)