{"record":{"id":"0e4a9404ce14f395","repo":"dotnet/maui","slug":"xc0040-0e4a94","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/ColorTypeConverter.cs","lineNumber":75,"sourceCode":"\t\t\t\t\tif (fieldReference != null)\n\t\t\t\t\t{\n\t\t\t\t\t\tyield return Instruction.Create(OpCodes.Ldsfld, fieldReference);\n\t\t\t\t\t\tyield break;\n\t\t\t\t\t}\n\n\t\t\t\t\tvar propertyGetterReference = module.ImportPropertyGetterReference(context.Cache, (\"Microsoft.Maui.Graphics\", \"Microsoft.Maui.Graphics\", \"Colors\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   color,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   isStatic: true,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   caseSensitive: false);\n\n\t\t\t\t\tif (propertyGetterReference != null)\n\t\t\t\t\t{\n\t\t\t\t\t\tyield return Instruction.Create(OpCodes.Call, propertyGetterReference);\n\t\t\t\t\t\tyield break;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} while (false);\n\t\t\tthrow new BuildException(BuildExceptionCode.Conversion, node, null, value, typeof(Color));\n\t\t}\n\t}\n}","sourceCodeStart":57,"sourceCodeEnd":78,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledConverters/ColorTypeConverter.cs#L57-L78","documentation":"XamlC error XC0040 from ColorTypeConverter. The compiled color converter accepts a '#'-prefixed hex string, the literal 'Default' (yields null), or the name of a member on Microsoft.Maui.Graphics.Colors (case-insensitive). Any other value throws XC0040.","triggerScenarios":"A Color-typed attribute is set to a value that is not hex, not 'Default', and not a Colors member — e.g. an HTML named color that is not in Maui's Colors, a typo, a localized name, or a non-color string.","commonSituations":"Using a CSS color name not present in Microsoft.Maui.Graphics.Colors; misspelling a color name; missing the '#' prefix; pasting an rgba()/hsl() string.","solutions":["Use '#'-prefixed hex (ARGB or RGB), e.g. BackgroundColor=\"#FF0000\".","If using a named color, verify it exists as a member of Microsoft.Maui.Graphics.Colors and spell it correctly (case-insensitive).","Avoid CSS-style functions (rgb()/hsl()); convert them to hex first."],"exampleFix":"<!-- before -->\n<Label TextColor=\"darkgrey\" />\n<!-- 'darkgrey' is not a Colors member (only 'Gray'/'DarkGray'); note 'lightgrey' is special-cased -->\n\n<!-- after -->\n<Label TextColor=\"#A9A9A9\" />","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use '#'-prefixed hex for colors to avoid named-color guesswork.","If using a named color, confirm it is a member of Microsoft.Maui.Graphics.Colors.","Avoid CSS color functions (rgb/hsl); convert to hex first."],"tags":["xaml","xamlc","color","compilation"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}