PrismLibrary/Prism · error · NotSupportedException

Module Reference Location is not supported in Maui

Error message

Module Reference Location is not supported in Maui

What it means

In Prism.Maui, the explicit interface implementation IModuleInfo.Ref getter always throws NotSupportedException because module-on-demand download via a ref/file location is not supported on MAUI. The setter is intentionally a no-op. Reading the Ref property of any ModuleInfo through the IModuleInfo interface will throw.

Solutions

  1. Remove code that reads or sets IModuleInfo.Ref in the MAUI app
  2. Deliver module assemblies as part of the app package instead of ref-based on-demand download
  3. Use #if or separate catalogs to share catalog-building code between WPF and MAUI targets

Example fix

// before
string path = ((IModuleInfo)moduleInfo).Ref;
// after
// MAUI does not support module Ref locations
var path = moduleInfo.ModuleType.Assembly.Location;
Defensive patterns

Strategy: type-guard

Validate before calling

if (moduleInfo is IModuleInfo mi && SupportsModuleRef(mi))
    Console.WriteLine(mi.Ref);
else
    Console.WriteLine("Ref not supported on MAUI");

Type guard

bool SupportsModuleRef(IModuleInfo mi) => mi is not global::Prism.Maui.Modularity.ModuleInfo; // MAUI ModuleInfo throws on Ref

Try / catch

try
{
    var reference = ((IModuleInfo)moduleInfo).Ref;
}
catch (NotSupportedException)
{
    // MAUI does not support module ref locations; fall back to embedded assembly
}

Prevention

When it happens

Trigger: Casting a Prism.Maui ModuleInfo to IModuleInfo and reading .Ref; code written for WPF/Prism desktop module loading (Ref="file://...") ported to MAUI; serialization or scanning code enumerating all IModuleInfo properties.

Common situations: Migrating WPF Prism modular apps to MAUI; generic tooling or DI scans that read every interface property; copying module catalog code from Prism.Wpf samples.

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


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

Appendix: source

Thrown at src/Maui/Prism.Maui/Modularity/ModuleInfo.cs:147

    /// </summary>
    /// <value>The list of modules that this module depends upon.</value>
    public Collection<string> DependsOn
    {
        get => _dependsOn ?? (_dependsOn = new Collection<string>());
        set => _dependsOn = value;
    }

    /// <summary>
    /// Specifies on which stage the Module will be initialized.
    /// </summary>
    public InitializationMode InitializationMode { get; set; }

    /// <summary>
    /// Reference to the location of the module assembly. Not Supported by Microsoft.Maui
    /// </summary>
    string IModuleInfo.Ref
    {
        get => throw new NotSupportedException(Resources.ModuleRefLocationNotSupported);
        set { }
    }

    /// <summary>
    /// Gets or sets the state of the <see cref="ModuleInfo"/> with regards to the module loading and initialization process.
    /// </summary>
    public ModuleState State { get; private set; }

    /// <summary>
    /// Gets or sets the state of the <see cref="ModuleInfo"/> with regards to the module loading and initialization process.
    /// </summary>
    ModuleState IModuleInfo.State
    {
        get => State;
        set => State = value;
    }
}

View on GitHub (pinned to 358118cd64)