unoplatform/uno · error · ArgumentNullException
type
Error message
type
What it means
Thrown by XamlAccessLevel.PrivateAccessTo(Type) when the type argument is null. The method reads type.AssemblyQualifiedName to forward to the string overload, so a null type is rejected first.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Xaml.Permissions/XamlAccessLevel.cs:67
return new XamlAccessLevel (assemblyName);
}
public static XamlAccessLevel PrivateAccessTo (string assemblyQualifiedTypeName)
{
if (assemblyQualifiedTypeName == null)
{
throw new ArgumentNullException ("assemblyQualifiedTypeName");
}
return new XamlAccessLevel (assemblyQualifiedTypeName);
}
public static XamlAccessLevel PrivateAccessTo (Type type)
{
if (type == null)
{
throw new ArgumentNullException ("type");
}
return new XamlAccessLevel (type.AssemblyQualifiedName);
}
internal XamlAccessLevel (AssemblyName assemblyAccessToAssemblyName)
{
AssemblyAccessToAssemblyName = assemblyAccessToAssemblyName;
}
internal XamlAccessLevel (string privateAccessToTypeName)
{
PrivateAccessToTypeName = privateAccessToTypeName;
}
public AssemblyName AssemblyAccessToAssemblyName { get; private set; }
public string PrivateAccessToTypeName { get; private set; }
}View on GitHub (pinned to 0418340488)
Solutions
- Resolve the Type with a non-failing lookup and null-check before calling.
- Catch TypeLoadException at the resolution step and surface a clearer domain error.
- Use the string overload only when you have a verified assembly-qualified name.
Example fix
// before
var t = Type.GetType("Missing.Foo, Missing"); // null
var lvl = XamlAccessLevel.PrivateAccessTo(t); // throws
// after
var t = Type.GetType("Missing.Foo, Missing") ?? throw new TypeLoadException();
var lvl = XamlAccessLevel.PrivateAccessTo(t); Defensive patterns
Strategy: validation
Validate before calling
var t = Type.GetType(qualifiedName) ?? throw new TypeLoadException(qualifiedName); var lvl = XamlAccessLevel.PrivateAccessTo(t);
Type guard
static bool IsTypeResolved(Type t) => t != null;
Prevention
- Resolve types via a single helper that throws on null.
- Validate config-supplied type names at startup against loaded assemblies.
- Account for platform/TFM differences that may remove a type.
When it happens
Trigger: Calling PrivateAccessTo((Type)null), typically from a reflection path that returned null (e.g. Type.GetType on an unresolvable name).
Common situations: Loading XAML access settings from config that names a type not present at runtime; cross-platform code where a type is conditionally compiled out; AOT/trimming that removed the type.
Related errors
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/dff80a22d369f1f8.
Report an issue: GitHub.