PrismLibrary/Prism · error · NotSupportedException
Resources.MustBeModuleGroupCatalog
Error message
Resources.MustBeModuleGroupCatalog
What it means
The AddGroup extension method on IModuleCatalog throws NotSupportedException when the catalog does not implement IModuleGroupsCatalog. Grouped module loading (loading several modules as one initialization group) is only supported by catalogs that implement the grouping interface; plain ModuleCatalog instances are not.
Solutions
- Use a catalog that implements IModuleGroupsCatalog (or add modules individually with AddModule and matching InitializationMode instead of groups).
- Check with `catalog is IModuleGroupsCatalog` before calling AddGroup and fall back to AddModule per module.
- Restructure module registration: instead of AddGroup, add each ModuleInfo with the desired WhenAvailable/OnDemand InitializationMode.
- If grouping is essential, implement/derive a catalog supporting IModuleGroupsCatalog.
Example fix
// before
IModuleCatalog catalog = new ModuleCatalog();
catalog.AddGroup(InitializationMode.OnDemand, "GroupA", moduleInfo1, moduleInfo2);
// after
if (catalog is IModuleGroupsCatalog grouped)
grouped.AddGroup(InitializationMode.OnDemand, "GroupA", moduleInfo1, moduleInfo2);
else
{
catalog.AddModule(moduleInfo1);
catalog.AddModule(moduleInfo2);
} Defensive patterns
Strategy: type-guard
Validate before calling
if (catalog is not IModuleGroupsCatalog)
throw new InvalidOperationException("AddGroup requires an IModuleGroupsCatalog; use AddModule per module instead."); Type guard
static bool SupportsGroups(IModuleCatalog c) => c is IModuleGroupsCatalog;
Try / catch
try { catalog.AddGroup(mode, refValue, modules); }
catch (NotSupportedException ex) when (ex.Message.Contains("ModuleGroupCatalog")) { logger.LogError(ex, "Catalog does not support module groups"); } Prevention
- Check catalog capabilities before using extension methods that require special interfaces.
- Prefer AddModule with InitializationMode when grouping is not essential.
- Keep catalog type consistent with the API surface your code uses.
- Re-verify extension usage after Prism version upgrades.
When it happens
Trigger: Calling catalog.AddGroup(...) on a ModuleCatalog, ConfigurationModuleCatalog, DirectoryModuleCatalog, or AggregateModuleCatalog instance that does not implement IModuleGroupsCatalog.
Common situations: Copy-pasting AddGroup usage from a sample that used a grouping-capable catalog; switching catalogs after migration (e.g. from a custom grouped catalog to the standard ModuleCatalog); NuGet/Prism version change where grouping interfaces moved or narrowed.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Module Reference Location is not supported in Maui
- Specified method is not supported.
- Resources.InvalidArgumentAssemblyUri
- Resources.ConfigurationStoreCannotBeNull
- Resources.ModulePathCannotBeNullOrEmpty
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/947de5396af1942d.
Report an issue: GitHub.
Appendix: source
Thrown at src/Wpf/Prism.Wpf/Modularity/IModuleCatalogExtensions.cs:165
/// <param name="mode">The <see cref="InitializationMode"/> to use.</param>
/// <typeparam name="T">The <see cref="IModule"/> type parameter.</typeparam>
/// <returns>The same <see cref="IModuleCatalog"/> instance with the added module.</returns>
public static IModuleCatalog AddModule<T>(this IModuleCatalog catalog, string name, InitializationMode mode)
where T : IModule =>
catalog.AddModule(new ModuleInfo(typeof(T), name, mode));
/// <summary>
/// Creates and adds a <see cref="ModuleInfoGroup"/> to the catalog.
/// </summary>
/// <param name="catalog">The catalog to add the module to.</param>
/// <param name="initializationMode">Stage on which the module group to be added will be initialized.</param>
/// <param name="refValue">Reference to the location of the module group to be added.</param>
/// <param name="moduleInfos">Collection of <see cref="ModuleInfo"/> included in the group.</param>
/// <returns>The same <see cref="IModuleCatalog"/> with the added module group.</returns>
public static IModuleCatalog AddGroup(this IModuleCatalog catalog, InitializationMode initializationMode, string refValue, params ModuleInfo[] moduleInfos)
{
if (!(catalog is IModuleGroupsCatalog groupSupport))
throw new NotSupportedException(Resources.MustBeModuleGroupCatalog);
if (moduleInfos == null)
throw new ArgumentNullException(nameof(moduleInfos));
ModuleInfoGroup newGroup = new ModuleInfoGroup
{
InitializationMode = initializationMode,
Ref = refValue
};
foreach (var info in moduleInfos)
{
newGroup.Add(info);
}
groupSupport.Items.Add(newGroup);
return catalog;View on GitHub (pinned to 358118cd64)