{"record":{"id":"55375221ae9fbaab","repo":"stride3d/stride","slug":"requested-conversion-is-not-supported","errorCode":null,"errorMessage":"Requested conversion is not supported.","messagePattern":"Requested conversion is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/ColorConverter.cs","lineNumber":127,"sourceCode":"                        (byte)((intValue >> 16) & 255));\n                }\n                if (targetType.IsAssignableFrom(typeof(SolidColorBrush)))\n                {\n                    return new SolidColorBrush(System.Windows.Media.Color.FromArgb(\n                        (byte)((intValue >> 24) & 255),\n                        (byte)(intValue & 255),\n                        (byte)((intValue >> 8) & 255),\n                        (byte)((intValue >> 16) & 255)));\n                }\n                if (targetType == typeof(string))\n                    return stringColor;\n            }\n\n#if DEBUG\n            if (value == null || value == DependencyProperty.UnsetValue)\n                return DependencyProperty.UnsetValue;\n\n            throw new NotSupportedException(\"Requested conversion is not supported.\");\n#else\n            return DependencyProperty.UnsetValue;\n#endif\n        }\n\n        /// <inheritdoc/>\n        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            if (targetType == typeof(object))\n                return value;\n\n            return Convert(value, targetType, parameter, culture);\n        }\n    }\n}\n","sourceCodeStart":109,"sourceCodeEnd":143,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/ColorConverter.cs#L109-L143","documentation":"ColorConverter.Convert throws this NotSupportedException in DEBUG builds when it receives a value it cannot convert and which is neither null nor DependencyProperty.UnsetValue. In release builds the same condition silently returns UnsetValue instead.","triggerScenarios":"Binding a string, brush, or arbitrary object that is not a Color/known convertible type to a property using ColorConverter; DEBUG configuration surfacing the misuse that release swallows.","commonSituations":"Binding a SolidColorBrush directly instead of its Color; binding a hex string without a preceding string-to-color converter; typos in the source path returning unexpected types.","solutions":["Bind a value of type Color (or a type the converter supports) to the property","Use Brush.Color via a path (e.g. Path=\"Background.(SolidColorBrush.Color)\") instead of the brush itself","Precede with a string-to-Color converter for hex strings","Test under Debug configuration to catch the mismatch early"],"exampleFix":"// before\n<Binding Path=\"Background\" Converter=\"{StaticResource ColorConverter}\"/>\n// after\n<Binding Path=\"Background.(SolidColorBrush.Color)\" Converter=\"{StaticResource ColorConverter}\"/>","handlingStrategy":"type-guard","validationCode":"if (value is Color) return; // safe\nif (value is SolidColorBrush brush) value = brush.Color; // normalize first","typeGuard":"bool IsConvertible(object v) => v is Color || v is string s && ColorConverter.ConvertFromString(s) is Color;","tryCatchPattern":"try { output = colorConverter.Convert(value, targetType, parameter, culture); }\ncatch (NotSupportedException) { return DependencyProperty.UnsetValue; }","preventionTips":["Bind Color values, not Brushes or raw objects","Access brush colors via property paths like (SolidColorBrush.Color)","Chain a string-to-Color converter for string inputs","Run in Debug to surface these binding type mistakes early"],"tags":["wpf","value-converter","color","binding"],"backgroundTag":"type-mismatch","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}