unoplatform/uno · error · ArgumentNullException
arrayType
Error message
arrayType
What it means
ArgumentNullException thrown by ArrayExtension (System.Xaml, ported from Mono) when its ArrayExtension(Type arrayType) constructor is called with a null Type. This constructor sets the element type of the array to build; a null type is meaningless, so it is rejected with parameter name 'arrayType'.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Windows.Markup/ArrayExtension.cs:59
items = new ArrayList ();
}
public ArrayExtension (Array elements)
{
if (elements == null)
{
throw new ArgumentNullException ("elements");
}
Type = elements.GetType ().GetElementType ();
items = new ArrayList (elements);
}
public ArrayExtension (Type arrayType)
{
if (arrayType == null)
{
throw new ArgumentNullException ("arrayType");
}
Type = arrayType;
items = new ArrayList ();
}
[ConstructorArgument ("arrayType")]
public Type Type { get; set; }
IList items;
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
public IList Items {
get { return items; }
}
public void AddChild (Object value)
{
// null is allowed.View on GitHub (pinned to 0418340488)
Solutions
- Resolve the Type before constructing and null-check it; surface a clear error if the type name cannot be resolved.
- Use the parameterless constructor and set the Type property explicitly after validation.
- Validate the type name string against loaded assemblies before Type.GetType.
Example fix
// before
var t = Type.GetType(configTypeName);
var ext = new ArrayExtension(t); // t may be null
// after
var t = Type.GetType(configTypeName)
?? throw new ConfigurationException($"Unknown array type '{configTypeName}'.");
var ext = new ArrayExtension(t); Defensive patterns
Strategy: validation
Validate before calling
static ArrayExtension ArrayExtOfType(string typeName) { var t = Type.GetType(typeName) ?? throw new ConfigurationException($"Unknown type '{typeName}'."); return new ArrayExtension(t); } Type guard
static bool IsResolvableType(string name) => Type.GetType(name) is not null;
Try / catch
try { return new ArrayExtension(t); } catch (ArgumentNullException ex) when (ex.ParamName == "arrayType") { throw new ConfigurationException("Array element type could not be resolved."); } Prevention
- Resolve and null-check Type via Type.GetType before constructing.
- Validate type names against loaded assemblies at startup.
- Use the parameterless constructor and set Type explicitly after validation.
When it happens
Trigger: Programmatic construction 'new ArrayExtension((Type)null)' or a reflection/code-gen path where the type argument resolves to null (e.g. Type.GetType returning null for an unresolvable name).
Common situations: Type.GetType("UnknownType") yielding null passed in, a config-driven array-type name that fails to resolve, or unit tests constructing the extension without a concrete type.
Related errors
- elements
- Type property must be set before calling ProvideValue method
- Item in the array must be an instance of '{0}'
- serviceProvider
- serviceProvider
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/6e12520ff8c113ad.
Report an issue: GitHub.