{"record":{"id":"85507071683a6b69","repo":"dotnet/wpf","slug":"cannot-convert-from-type-imagesourcetypeconverter","errorCode":null,"errorMessage":"Cannot convert from type.","messagePattern":"Cannot convert from type\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/ImageSourceTypeConverter.cs","lineNumber":112,"sourceCode":"        /// The Object to convert.\n        /// </param>\n        /// <returns>\n        /// An Object that represents the converted value.\n        /// </returns>\n        public\n        override\n        object\n        ConvertFrom(\n            ITypeDescriptorContext              context,\n            System.Globalization.CultureInfo    culture,\n            object                              value\n            )\n        {\n            ArgumentNullException.ThrowIfNull(value);\n\n            if (!IsSupportedType(value.GetType()))\n            {\n                throw new NotSupportedException(SR.Converter_ConvertFromNotSupported);\n            }\n\n            throw new NotImplementedException();\n        }\n\n        /// <summary>\n        /// Converts the given value object to the specified type,\n        /// using the arguments.\n        /// </summary>\n        /// <param name=\"context\">\n        /// An ITypeDescriptorContext that provides a format context.\n        /// </param>\n        /// <param name=\"culture\">\n        /// A CultureInfo object. If null is passed, the current\n        /// culture is assumed.\n        /// </param>\n        /// <param name=\"value\">\n        /// The Object to convert.","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/ImageSourceTypeConverter.cs#L94-L130","documentation":"ImageSourceTypeConverter.ConvertFrom is not implemented: after validating that the value is a supported source type, it throws NotImplementedException. Converting any object (e.g. a string URI or stream) into a BitmapSource via this converter is unsupported by design — use BitmapFrame/Create APIs instead.","triggerScenarios":"Calling ImageSourceTypeConverter.ConvertFrom(context, culture, value) with any supported type value; TypeConverter.ConvertFromString / ConvertFrom invoked by parsers or designers on an image-source property handled by this converter.","commonSituations":"XAML or designer pipelines attempting to convert an image path string via this converter; developers using TypeDescriptor to build BitmapSource values during XPS serialization setup.","solutions":["Do not use ImageSourceTypeConverter for value creation; construct the image with BitmapFrame.Create(uri) or new BitmapImage(new Uri(path)).","If invoked indirectly by a framework, register a different TypeConverter that implements ConvertFrom.","Catch NotImplementedException and perform the conversion manually via BitmapFrame.Create."],"exampleFix":"// before\nvar source = (BitmapSource)converter.ConvertFrom(context, culture, imagePath);\n\n// after\nvar source = (BitmapSource)BitmapFrame.Create(new Uri(imagePath));","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    source = (BitmapSource)converter.ConvertFrom(context, culture, value);\n}\ncatch (NotImplementedException)\n{\n    source = BitmapFrame.Create((Uri)value); // manual construction\n}","preventionTips":["Build image sources with BitmapImage/BitmapFrame constructors, not ImageSourceTypeConverter.ConvertFrom.","Remember this converter only supports ConvertTo within XPS serialization.","Route XAML image parsing through the standard WPF image-source converter instead."],"tags":["wpf","xps","typeconverter","not-implemented"],"backgroundTag":"method-not-implemented","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}