dotnet/maui · error · BuildException
XC0007
XC0007
Error message
Enum value not found for "{0}". What it means
Thrown after the XAML compiler iterates every field of the target enum and none matches the trimmed value(s) supplied in the attribute. The `found` flag stays false, meaning the literal name written in XAML does not exist as a member of the resolved enum type.
Source
Thrown at src/Controls/src/Build.Tasks/NodeILExtensions.cs:407
i |= (int)field.Constant;
break;
case "System.UInt32":
ui |= (uint)field.Constant;
break;
case "System.Int64":
l |= (long)field.Constant;
break;
case "System.UInt64":
ul |= (ulong)field.Constant;
break;
}
found = true;
}
}
}
if (!found)
throw new BuildException(BuildExceptionCode.EnumValueMissing, lineInfo, null, value);
switch (typeRef.FullName)
{
case "System.Byte":
return Create(Ldc_I4, (int)b);
case "System.SByte":
return Create(Ldc_I4, (int)sb);
case "System.Int16":
return Create(Ldc_I4, (int)s);
case "System.UInt16":
return Create(Ldc_I4, (int)us);
case "System.Int32":
return Create(Ldc_I4, (int)i);
case "System.UInt32":
return Create(Ldc_I4, (uint)ui);
case "System.Int64":
return Create(Ldc_I4, (long)l);
case "System.UInt64":View on GitHub (pinned to f377ff1c5e)
Solutions
- Verify the exact enum member name (names are case-sensitive).
- Confirm which enum type the property actually expects and that the correct assembly/namespace is referenced.
- Rebuild the project referencing the assembly that defines the enum so the compiler sees the current members.
Example fix
<!-- before --> <StackLayout Orientation="Horz" /> <!-- after --> <StackLayout Orientation="Horizontal" />
Defensive patterns
Strategy: validation
Validate before calling
// Verify the value is a defined member name (case-sensitive) of the expected enum
static bool IsDefinedEnumName(Type enumType, string xamlValue)
=> xamlValue.Split(',').Select(v => v.Trim())
.All(v => Enum.GetNames(enumType).Contains(v)); Type guard
static bool IsValidEnumValue<T>(string value) where T : struct, Enum
=> value.Split(',').Select(v => v.Trim()).All(v => Enum.IsDefined(typeof(T), v)); Prevention
- Cross-check enum member names against the source enum (names are case-sensitive).
- After upgrading a package, re-scan XAML for enum values that may have been renamed.
- Keep the referenced assembly current so the compiler sees the latest members.
When it happens
Trigger: An attribute resolves to an enum but the value string (after split-on-comma and trim) matches no field name on that enum, e.g. `Orientation="Horz"` where the enum defines `Horizontal`.
Common situations: Typo in an enum member name; the member was renamed or removed in a newer package version; the wrong enum type was resolved due to a namespace/assembly mismatch.
Related errors
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/0552051952fde502.
Report an issue: GitHub.