dotnet/maui · error · BuildException
XC0003
XC0003
Error message
Missing mandatory property "{0}" on "{1}". What it means
Thrown when a type exposes a parameterized constructor whose parameters are all decorated with [Parameter] (the Maui parameterized-ctor convention), ValidateCtorArguments flagged a missing mandatory parameter, and no parameterless fallback constructor exists. The message names the missing property and the type.
Source
Thrown at src/Controls/src/Build.Tasks/CreateObjectVisitor.cs:168
md.HasParameters &&
md.Parameters.All(
pd =>
pd.CustomAttributes.Any(
ca =>
ca.AttributeType.FullName ==
"Microsoft.Maui.Controls.ParameterAttribute")));
}
string missingCtorParameter = null;
if (parameterizedCtorInfo != null && ValidateCtorArguments(parameterizedCtorInfo, node, out missingCtorParameter))
{
ctorInfo = parameterizedCtorInfo;
// IL_0000: ldstr "foo"
Context.IL.Append(PushCtorArguments(parameterizedCtorInfo.ResolveGenericParameters(typeref, Module), node));
}
ctorInfo ??= typedef.Methods.FirstOrDefault(md => md.IsConstructor && !md.HasParameters && !md.IsStatic);
if (parameterizedCtorInfo != null && ctorInfo == null)
//there was a parameterized ctor, we didn't use it
throw new BuildException(BuildExceptionCode.PropertyMissing, node, null, missingCtorParameter, typedef.FullName);
var ctorinforef = ctorInfo?.ResolveGenericParameters(typeref, Module);
var factorymethodinforef = factoryMethodInfo?.ResolveGenericParameters(typeref, Module);
var implicitOperatorref = typedef.Methods.FirstOrDefault(md =>
md.IsPublic &&
md.IsStatic &&
md.IsSpecialName &&
md.Name == "op_Implicit" && md.Parameters[0].ParameterType.FullName == "System.String");
// The old Forms.Color was a struct, so the following BuildException wasn't thrown because IsValueType returned true.
// MGColor is a class, so IsValueType is false, but there's no parameterless constructor or factory; there's a
// TypeConverter. So adding this bool as a check for this condition temporarily.
bool isColor = typedef.FullName == "Microsoft.Maui.Graphics.Color";
if (!isColor && !typedef.IsValueType && ctorInfo == null && factoryMethodInfo == null)
{
throw new BuildException(BuildExceptionCode.ConstructorDefaultMissing, node, null, typedef.FullName);
}
View on GitHub (pinned to f377ff1c5e)
Solutions
- Add the missing property/attribute named in the error message to the element.
- Check the type's [Parameter]-decorated constructor to see which properties are mandatory.
- If the type is yours, add a parameterless constructor or make the parameter optional.
- Fix any typos in property names so they bind to the [Parameter] arguments.
Example fix
// before <MyControl /> <!-- MyControl(..) requires Text via [Parameter] --> // after <MyControl Text="Hello" />
Defensive patterns
Strategy: validation
Validate before calling
// List the [Parameter]-mandatory properties of a type's parameterized ctor
static IEnumerable<string> MandatoryCtorParams(Type t) =>
t.GetConstructors()
.SelectMany(c => c.GetParameters()
.Where(p => p.GetCustomAttribute<ParameterAttribute>() != null)
.Select(p => p.Name!)); Prevention
- Document [Parameter]-required properties on XAML-usable types.
- Supply all mandatory attributes in XAML, or add a parameterless ctor.
When it happens
Trigger: Declaring an element in XAML but omitting a required [Parameter]-marked ctor argument; typo in the property name so it isn't recognized; the type relies solely on a parameterized ctor and the XAML didn't supply all params.
Common situations: Using Maui controls/types that require constructor arguments (e.g. certain gestures or custom controls); partial XAML where a required attribute was dropped during refactor.
Related errors
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/8495055001dc446d.
Report an issue: GitHub.