{"record":{"id":"c70e5c2d3f18fddd","repo":"PrismLibrary/Prism","slug":"value-cannot-be-null-parameter-type","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'type')","messagePattern":"Value cannot be null\\. \\(Parameter 'type'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Modularity/ModuleInfo.cs","lineNumber":38,"sourceCode":"    public ModuleInfo()\n    {\n    }\n\n    /// <summary>\n    /// Initializes a new instance of <see cref=\"ModuleInfo\"/>.\n    /// </summary>\n    /// <param name=\"name\">The module's name.</param>\n    /// <param name=\"type\">The module <see cref=\"Type\"/>'s AssemblyQualifiedName.</param>\n    /// <param name=\"dependsOn\">The modules this instance depends on.</param>\n    /// <exception cref=\"ArgumentNullException\">An <see cref=\"ArgumentNullException\"/> is thrown if <paramref name=\"dependsOn\"/> is <see langword=\"null\"/>.</exception>\n    public ModuleInfo(string name, string type, params string[] dependsOn)\n    {\n        if (string.IsNullOrWhiteSpace(name))\n            throw new ArgumentNullException(nameof(name));\n        if (dependsOn == null)\n            throw new ArgumentNullException(nameof(dependsOn));\n\n        ModuleType = Type.GetType(type) ?? throw new ArgumentNullException(nameof(type));\n        ModuleName = name;\n        foreach (string dependency in dependsOn)\n        {\n            if (!DependsOn.Contains(dependency))\n            {\n                DependsOn.Add(dependency);\n            }\n        }\n    }\n\n    /// <summary>\n    /// Initializes a new instance of <see cref=\"ModuleInfo\"/>.\n    /// </summary>\n    /// <param name=\"name\">The module's name.</param>\n    /// <param name=\"type\">The module's type.</param>\n    public ModuleInfo(string name, string type)\n        : this(name, type, Array.Empty<string>())\n    {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Modularity/ModuleInfo.cs#L20-L56","documentation":"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').","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nvar info = new ModuleInfo(\"FooModule\", \"MyApp.Modules.FooModule\"); // Type.GetType returns null\n// after\nvar info = new ModuleInfo(\"FooModule\", typeof(MyApp.Modules.FooModule).AssemblyQualifiedName);","handlingStrategy":"validation","validationCode":"var moduleType = Type.GetType(typeName) ?? AppDomain.CurrentDomain.GetAssemblies()\n    .Select(a => a.GetType(typeName)).FirstOrDefault(t => t is not null);\nif (moduleType is null)\n    throw new InvalidOperationException($\"Module type '{typeName}' not found\");\nvar info = new ModuleInfo(name, moduleType.AssemblyQualifiedName);","typeGuard":"bool IsResolvableType(string name) => Type.GetType(name, throwOnError: false) is not null;","tryCatchPattern":"try\n{\n    var info = new ModuleInfo(name, typeName);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"type\")\n{\n    logger.LogError(ex, \"Type '{TypeName}' unresolved — use AssemblyQualifiedName and ensure the assembly is loaded\", typeName);\n    throw;\n}","preventionTips":["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"],"tags":["null-argument","type-resolution","modularity","prism"],"backgroundTag":"null-argument","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}