PrismLibrary/Prism · error · ArgumentNullException
Value cannot be null. (Parameter 'type')
Error message
Value cannot be null. (Parameter 'type')
What it means
In the ModuleInfo(string, string, params string[]) constructor, ModuleType is assigned as Type.GetType(type) ?? throw new ArgumentNullException(nameof(type)), so a null type string — or a type string that Type.GetType cannot resolve — raises ArgumentNullException('type').
Solutions
- Pass typeof(FooModule).AssemblyQualifiedName as the type argument
- If using a short name, resolve the Type yourself with a fallback search across loaded assemblies before constructing ModuleInfo
- Ensure the module assembly is referenced and loaded
Example fix
// before
var info = new ModuleInfo("FooModule", "MyApp.Modules.FooModule"); // Type.GetType returns null
// after
var info = new ModuleInfo("FooModule", typeof(MyApp.Modules.FooModule).AssemblyQualifiedName); Defensive patterns
Strategy: validation
Validate before calling
var moduleType = Type.GetType(typeName) ?? AppDomain.CurrentDomain.GetAssemblies()
.Select(a => a.GetType(typeName)).FirstOrDefault(t => t is not null);
if (moduleType is null)
throw new InvalidOperationException($"Module type '{typeName}' not found");
var info = new ModuleInfo(name, moduleType.AssemblyQualifiedName); Type guard
bool IsResolvableType(string name) => Type.GetType(name, throwOnError: false) is not null;
Try / catch
try
{
var info = new ModuleInfo(name, typeName);
}
catch (ArgumentNullException ex) when (ex.ParamName == "type")
{
logger.LogError(ex, "Type '{TypeName}' unresolved — use AssemblyQualifiedName and ensure the assembly is loaded", typeName);
throw;
} Prevention
- Always store AssemblyQualifiedName in module configuration
- Reference the module assembly from the host app or load it explicitly before catalog building
- Test type resolution in unit tests to catch renamed/moved module classes
When it happens
Trigger: new ModuleInfo("Foo", null); or Type.GetType("FooModule") failing because the name lacks the assembly-qualified name and the module lives in another assembly, so GetType returns null.
Common situations: Configuration storing only the class name instead of AssemblyQualifiedName; module assembly not referenced/loaded; typos in the type string; assemblies not resolvable by Type.GetType in the current context.
Related errors
- Value cannot be null. (Parameter 'name')
- Value cannot be null. (Parameter 'dependsOn')
- Value cannot be null. (Parameter 'moduleInitializer')
- Value cannot be null. (Parameter 'moduleCatalog')
- configureSegment
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/c70e5c2d3f18fddd.
Report an issue: GitHub.
Appendix: source
Thrown at src/Maui/Prism.Maui/Modularity/ModuleInfo.cs:38
public ModuleInfo()
{
}
/// <summary>
/// Initializes a new instance of <see cref="ModuleInfo"/>.
/// </summary>
/// <param name="name">The module's name.</param>
/// <param name="type">The module <see cref="Type"/>'s AssemblyQualifiedName.</param>
/// <param name="dependsOn">The modules this instance depends on.</param>
/// <exception cref="ArgumentNullException">An <see cref="ArgumentNullException"/> is thrown if <paramref name="dependsOn"/> is <see langword="null"/>.</exception>
public ModuleInfo(string name, string type, params string[] dependsOn)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentNullException(nameof(name));
if (dependsOn == null)
throw new ArgumentNullException(nameof(dependsOn));
ModuleType = Type.GetType(type) ?? throw new ArgumentNullException(nameof(type));
ModuleName = name;
foreach (string dependency in dependsOn)
{
if (!DependsOn.Contains(dependency))
{
DependsOn.Add(dependency);
}
}
}
/// <summary>
/// Initializes a new instance of <see cref="ModuleInfo"/>.
/// </summary>
/// <param name="name">The module's name.</param>
/// <param name="type">The module's type.</param>
public ModuleInfo(string name, string type)
: this(name, type, Array.Empty<string>())
{View on GitHub (pinned to 358118cd64)