unoplatform/uno · error · ArgumentNullException
type
Error message
type
What it means
Thrown by the TypeExtension(Type type) constructor when a null Type is supplied. The constructor stores the argument into the Type property which ProvideValue returns directly, so a null would propagate; the check rejects it at the boundary.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Windows.Markup/TypeExtension.cs:55
public TypeExtension ()
{
}
public TypeExtension (string typeName)
{
if (typeName == null)
{
throw new ArgumentNullException ("typeName");
}
TypeName = typeName;
}
public TypeExtension (Type type)
{
if (type == null)
{
throw new ArgumentNullException ("type");
}
Type = type;
}
[ConstructorArgument ("type")]
[DefaultValue (null)]
public Type Type { get; set; }
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public string TypeName { get; set; }
public override object ProvideValue (IServiceProvider serviceProvider)
{
if (Type != null)
{
return Type;
}
View on GitHub (pinned to 0418340488)
Solutions
- Pass a concrete, non-null System.Type obtained via typeof() or a successful Type.GetType call.
- Guard the type resolution result before constructing the extension.
- Fall back to the string constructor with an assembly-qualified name when the Type is unavailable.
Example fix
// before
var t = Type.GetType("MyLib.Foo, MyLib");
var ext = new TypeExtension(t); // throws if getType returned null
// after
var t = Type.GetType("MyLib.Foo, MyLib") ?? throw new TypeLoadException("MyLib.Foo missing");
var ext = new TypeExtension(t); Defensive patterns
Strategy: validation
Validate before calling
Type t = ResolveType() ?? throw new TypeLoadException("type not found");
var ext = new TypeExtension(t); Type guard
static bool IsKnownType(Type t) => t != null && !t.IsGenericTypeDefinition || t != null;
Prevention
- Resolve types through a single helper that throws on null so callers never see this error.
- Use typeof() where possible to get compile-time guarantees.
- Watch platform-conditional types that may be absent on a TFM.
When it happens
Trigger: Constructing new TypeExtension((Type)null), or passing a typeof() expression whose target could not be resolved at compile/runtime.
Common situations: Building a TypeExtension from a reflection lookup that returned null; platform-conditional code where a type may not exist on a target TFM.
Related errors
- typeName
- serviceProvider
- Either TypeName or Type must be filled before calling Provid
- serviceProvider does not provide IXamlTypeResolver service.
- Type '{0}' is not resolved as a valid type by the type resol
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/c1469af50b01e247.
Report an issue: GitHub.