{"record":{"id":"02659792bd39c0f4","repo":"dotnet/maui","slug":"xc0040-026597","errorCode":"XC0040","errorMessage":"Cannot convert value \"{0}\" to \"{1}\".","messagePattern":"Cannot convert value \"(.+?)\" to \"(.+?)\"\\.","errorType":"error_code","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/CompiledConverters/BrushTypeConverter.cs","lineNumber":43,"sourceCode":"\t\t\t\tyield return Instruction.Create(OpCodes.Newobj, module.ImportCtorReference(context.Cache, (\"Microsoft.Maui.Controls\", \"Microsoft.Maui.Controls\", \"SolidColorBrush\"), parameterTypes: new[] {\n\t\t\t\t\t\t(\"Microsoft.Maui.Graphics\", \"Microsoft.Maui.Graphics\", \"Color\")}));\n\n\t\t\t\tyield break;\n\t\t\t}\n\n\t\t\tvar propertyGetterReference = module.ImportPropertyGetterReference(context.Cache,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\"Microsoft.Maui.Controls\", \"Microsoft.Maui.Controls\", \"Brush\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisStatic: true,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcaseSensitive: false);\n\n\t\t\tif (propertyGetterReference != null)\n\t\t\t{\n\t\t\t\tyield return Instruction.Create(OpCodes.Call, propertyGetterReference);\n\t\t\t\tyield break;\n\t\t\t}\n\t\t}\n\t\tthrow new BuildException(BuildExceptionCode.Conversion, node, null, value, typeof(Brush));\n\t}\n}\n","sourceCodeStart":25,"sourceCodeEnd":46,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledConverters/BrushTypeConverter.cs#L25-L46","documentation":"XamlC error XC0040 from BrushTypeConverter. The compiled brush converter accepts either a '#'-prefixed hex color (converted to a SolidColorBrush) or the name of a static property on the Brush type (e.g. a named brush). Anything else, including an empty value or an unrecognized name, throws XC0040.","triggerScenarios":"A Brush-typed attribute is set to a value that is neither '#RRGGBB' hex nor a recognized static Brush property — e.g. a bare color name without '#', a typo, or an empty string.","commonSituations":"Using a color name where a brush is expected without the '#' prefix; misspelling a named brush; assuming an HTML/CSS gradient string is supported.","solutions":["Use '#'-prefixed hex for a solid color, e.g. Background=\"#3498DB\".","Use a valid named static Brush property if you need a predefined brush.","If you only need a color, ensure the target expects a Brush and prefix hex with '#'."],"exampleFix":"<!-- before -->\n<Frame Background=\"CornflowerBlue\" />\n<!-- 'CornflowerBlue' is a Color name, not a Brush property -->\n\n<!-- after -->\n<Frame Background=\"#FF6495ED\" />","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["For solid colors use '#'-prefixed hex on Brush-typed properties.","Reference only real static Brush properties for named brushes.","Do not put a bare color name on a Brush property without the '#' prefix."],"tags":["xaml","xamlc","brush","compilation"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}