{"record":{"id":"fc99768d8881cc6f","repo":"dotnet/maui","slug":"xc0005","errorCode":"XC0005","errorMessage":"Missing constructor for \"{0}\" with matching x:Arguments.","messagePattern":"Missing constructor for \"(.+?)\" with matching x:Arguments\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/CreateObjectVisitor.cs","lineNumber":130,"sourceCode":"\t\t\t\t\tif (!node.SkipProperties.Contains(prop.Key))\n\t\t\t\t\t\tnode.SkipProperties.Add(prop.Key);\n\t\t\t\tnode.CollectionItems.Clear();\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tMethodDefinition factoryCtorInfo = null;\n\t\t\tMethodDefinition factoryMethodInfo = null;\n\t\t\tMethodDefinition parameterizedCtorInfo = null;\n\t\t\tMethodDefinition ctorInfo = null;\n\n\t\t\tif (node.Properties.ContainsKey(XmlName.xArguments) && !node.Properties.ContainsKey(XmlName.xFactoryMethod))\n\t\t\t{\n\t\t\t\tfactoryCtorInfo = typedef.AllMethods(Context.Cache).FirstOrDefault(md => md.methodDef.IsConstructor &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t!md.methodDef.IsStatic &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmd.methodDef.HasParameters &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmd.methodDef.MatchXArguments(node, typeref, Module, Context)).methodDef;\n\t\t\t\tctorInfo = factoryCtorInfo ?? throw new BuildException(BuildExceptionCode.ConstructorXArgsMissing, node, null, typedef.FullName);\n\t\t\t\tif (!typedef.IsValueType) //for ctor'ing typedefs, we first have to ldloca before the params\n\t\t\t\t\tContext.IL.Append(PushCtorXArguments(factoryCtorInfo.ResolveGenericParameters(typeref, Module), node));\n\t\t\t}\n\t\t\telse if (node.Properties.TryGetValue(XmlName.xFactoryMethod, out INode value))\n\t\t\t{\n\t\t\t\tvar factoryMethod = (string)(value as ValueNode).Value;\n\t\t\t\tfactoryMethodInfo = typedef.AllMethods(Context.Cache).FirstOrDefault(md => !md.methodDef.IsConstructor &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  md.methodDef.Name == factoryMethod &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  md.methodDef.IsStatic &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  md.methodDef.MatchXArguments(node, typeref, Module, Context)).methodDef;\n\t\t\t\tif (factoryMethodInfo == null)\n\t\t\t\t\tthrow new BuildException(BuildExceptionCode.MethodStaticMissing, node, null, typedef.FullName, factoryMethod, null);\n\n\t\t\t\tContext.IL.Append(PushCtorXArguments(factoryMethodInfo.ResolveGenericParameters(typeref, Module), node));\n\t\t\t}\n\t\t\tif (ctorInfo == null && factoryMethodInfo == null)\n\t\t\t{\n\t\t\t\tparameterizedCtorInfo = typedef.Methods.FirstOrDefault(md => md.IsConstructor &&","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CreateObjectVisitor.cs#L112-L148","documentation":"Thrown by CreateObjectVisitor when an element declares x:Arguments but no accessible instance constructor on the type matches those argument types (MatchXArguments failed for every candidate). The compiler needs a concrete constructor to emit the newobj call.","triggerScenarios":"Listing x:Arguments whose types/signature do not match any constructor; constructor is internal/private; using a generic type whose ctor needs type-arg resolution; argument types are wrong (e.g. x:Int where a double ctor is expected).","commonSituations":"Calling a struct/value-type ctor with wrong arg count; passing a string where a typed converter would be needed at runtime but not at compile time; mismatched overload after a package update changed available constructors.","solutions":["Inspect the type's public constructors and align x:Arguments element types/count to one of them.","Use the correct x:Int/x:Double/x:String wrapper elements so argument types match.","If the matching ctor is non-public, make it public or add InternalsVisibleTo.","If no ctor fits, add a parameterized factory and use x:FactoryMethod instead."],"exampleFix":"// before\n<Size>\n  <x:Arguments>\n    <x:String>10</x:String>\n    <x:String>20</x:String>\n  </x:Arguments>\n</Size>\n// after\n<Size>\n  <x:Arguments>\n    <x:Double>10</x:Double>\n    <x:Double>20</x:Double>\n  </x:Arguments>\n</Size>","handlingStrategy":"validation","validationCode":"// Verify a constructor matches the x:Arguments you intend to supply\nstatic bool HasMatchingCtor(Type t, Type[] argTypes) =>\n    t.GetConstructors().Any(c => c.GetParameters()\n        .Select(p => p.ParameterType).SequenceEqual(argTypes));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap each x:Argument in the exact primitive type (x:Int, x:Double, x:String).","Consult the type's constructors before authoring x:Arguments.","Prefer x:FactoryMethod when no ctor overload fits."],"tags":["xaml","xamlc","x-arguments","constructor","object-construction","build-time"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}