{"record":{"id":"7d7eef8356744df0","repo":"dotnet/maui","slug":"xc0006","errorCode":"XC0006","errorMessage":"No static method found for \"{0}::{1} ({2})\".","messagePattern":"No static method found for \"(.+?)::(.+?) \\((.+?)\\)\"\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/CreateObjectVisitor.cs","lineNumber":142,"sourceCode":"\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 &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t !md.IsStatic &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t md.HasParameters &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t md.Parameters.All(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t pd =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t pd.CustomAttributes.Any(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ca =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ca.AttributeType.FullName ==\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \"Microsoft.Maui.Controls.ParameterAttribute\")));\n\t\t\t}\n\t\t\tstring missingCtorParameter = null;\n\t\t\tif (parameterizedCtorInfo != null && ValidateCtorArguments(parameterizedCtorInfo, node, out missingCtorParameter))\n\t\t\t{","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CreateObjectVisitor.cs#L124-L160","documentation":"Thrown when an element declares x:FactoryMethod but no public static method with that name on the type matches the supplied x:Arguments (or no such static method exists at all). CreateObjectVisitor searches AllMethods for a non-constructor static method whose name and arguments line up.","triggerScenarios":"Misspelling the factory method name; the method is an instance method (not static); argument signature mismatch; method was renamed/removed in a newer version; method is private/internal.","commonSituations":"Using a builder/factory pattern (e.g. MyType.Create(...)); refactoring renamed the factory; pointing x:FactoryMethod at an instance method by mistake.","solutions":["Confirm the method is public and static and its parameter types match x:Arguments exactly.","Correct the spelling/casing of the method name.","If only an instance factory exists, instantiate first then call it, or add a static wrapper.","Pin/upgrade the package to a version exposing the expected factory signature."],"exampleFix":"// before\n<Widget x:FactoryMethod=\"Create\">\n  <x:Arguments><x:String>id</x:String></x:Arguments>\n</Widget>\n  <!-- but Widget.Create takes (int) -->\n// after\n<Widget x:FactoryMethod=\"FromId\">\n  <x:Arguments><x:String>id</x:String></x:Arguments>\n</Widget>","handlingStrategy":"validation","validationCode":"// Confirm a public static method with the given name/args exists\nstatic bool HasStaticFactory(Type t, string name, Type[] argTypes) =>\n    t.GetMethods(BindingFlags.Public | BindingFlags.Static)\n     .Any(m => m.Name == name && m.GetParameters().Select(p => p.ParameterType).SequenceEqual(argTypes));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the exact static factory method name and signature.","Ensure the factory is public and static, not an instance method.","Re-validate factory references after package upgrades."],"tags":["xaml","xamlc","x-factorymethod","static-method","object-construction","build-time"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}