dotnet/maui · error · BuildException
XC0044
XC0044
Error message
Binding: "{0}" cannot be parsed as an index for a "{1}". What it means
Thrown in DigProperties when the resolved indexer takes an enum parameter, but the indexArg string does not match any static field name on that enum. The compiler looks up `indexTypeDef.Fields.FirstOrDefault(f => f.IsStatic && f.Name == indexArg)` and, finding none, throws BindingIndexerParse.
Source
Thrown at src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs:987
// long/ulong enums require Ldc_I8; all narrower types fit in Ldc_I4.
var underlyingType = indexTypeDef.GetEnumUnderlyingType();
if (underlyingType.FullName == "System.Int64" || underlyingType.FullName == "System.UInt64")
{
var longValue = underlyingType.FullName == "System.UInt64"
? unchecked((long)Convert.ToUInt64(enumField.Constant))
: Convert.ToInt64(enumField.Constant);
yield return Create(Ldc_I8, longValue);
}
else
{
var enumValue = underlyingType.FullName == "System.UInt32"
? unchecked((int)Convert.ToUInt32(enumField.Constant))
: Convert.ToInt32(enumField.Constant);
yield return Create(Ldc_I4, enumValue);
}
}
else
throw new BuildException(BindingIndexerParse, lineInfo, null, indexArg, property.Name);
}
else
throw new BuildException(BindingIndexerParse, lineInfo, null, indexArg, property.Name);
}
}
}
if (indexArg != null && property == null)
yield return Create(Ldelem_Ref);
else
{
var getMethod = module.ImportReference((module.ImportReference(property.GetMethod)).ResolveGenericParameters(propDeclTypeRef, module));
if (property.GetMethod.IsVirtual)
yield return Create(Callvirt, getMethod);
else
yield return Create(Call, getMethod);
}View on GitHub (pinned to f377ff1c5e)
Solutions
- Use a valid, correctly-spelled enum member name as the index argument.
- Confirm the indexer's enum type and its current members.
- Rebuild referencing assemblies if the enum changed.
Example fix
<!-- before -->
<Label Text="{Binding Lookup[Magrent], x:DataType=vm:Vm}" />
<!-- after (valid enum member) -->
<Label Text="{Binding Lookup[Magenta], x:DataType=vm:Vm}" /> Defensive patterns
Strategy: validation
Validate before calling
// The indexer argument must be a member of the enum key type
static bool IsValidEnumIndex(Type enumKey, string indexArg)
=> enumKey.IsEnum && Enum.GetNames(enumKey).Contains(indexArg); Type guard
static bool IsEnumMember<T>(string name) where T : struct, Enum => Enum.IsDefined(typeof(T), name);
Prevention
- Use exact, defined enum member names as enum-indexer arguments.
- Keep enum members stable for types used as binding keys.
- Re-validate bindings after renaming enum members.
When it happens
Trigger: Binding to an enum-keyed indexer with a value that is not a defined enum member, e.g. `{Binding Map[MissingKey]}` where the enum has no `MissingKey` member.
Common situations: Typo in the enum member used as a key; the enum member was renamed/removed; wrong enum type resolved for the indexer.
Related errors
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/46e4dd51a45fbf39.
Report an issue: GitHub.