dotnet/wpf · error · NotSupportedException
SR.Image_NoPixelFormatFound
Error message
SR.Image_NoPixelFormatFound
What it means
CreatePixelFormatInfo queries WIC (via IWICImagingFactory::CreateComponentInfo) for component info about a pixel format GUID. If WIC returns WINCODEC_ERR_COMPONENTNOTFOUND or WINCODEC_ERR_COMPONENTINITIALIZEFAILURE, the method throws NotSupportedException with Image_NoPixelFormatFound, meaning WIC has no registered component describing that pixel format. This indicates the pixel format GUID is not recognized by the installed WIC infrastructure.
Solutions
- Only request pixel-format info for standard WIC-backed formats (Bgr32, Pbgra32, Gray8, etc.); skip Extended formats
- Reinstall/repair the WIC codec or OS imaging components if a third-party codec format is expected
- Check the format's GUID against known WIC GUIDs before calling, and guard with try/catch NotSupportedException
- Fall back to default bit-depth/channel metadata computed in managed code when WIC info is unavailable
Example fix
// before
var info = GetPixelFormatInfo(pixelFormat); // may throw for Extended
// after
if (pixelFormat == PixelFormats.Extended) return DefaultPixelFormatInfo();
try { return GetPixelFormatInfo(pixelFormat); }
catch (NotSupportedException) { return DefaultPixelFormatInfo(); } Defensive patterns
Strategy: try-catch
Validate before calling
if (pixelFormat == PixelFormats.Extended) throw new SkipPixelFormatInfoException();
Type guard
bool IsWicBackedFormat(PixelFormat pf) => pf != PixelFormats.Default && pf != PixelFormats.Extended;
Try / catch
try { return CreatePixelFormatInfo(pf); }
catch (NotSupportedException ex) { log(ex); return FallbackPixelFormatInfo(pf); } Prevention
- Query info only for standard WIC formats
- Verify third-party WIC codecs are installed when their formats are expected
- Repair OS imaging components if standard formats fail
- Cache format info to limit repeated WIC queries
When it happens
Trigger: Calling pixelFormatInfo / pixel-format metadata APIs on a PixelFormat whose WIC GUID is not registered on the machine (e.g. PixelFormat.Extended, or formats from third-party WIC codecs that are missing).
Common situations: Running on systems where third-party WIC codecs were uninstalled; querying metadata for PixelFormats.Extended or other non-WIC-backed formats; broken WIC registry entries after OS servicing.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- SR.Image_BadPixelFormat
- Image_CantDealWithStream
- Image_CantDealWithUri
- Image_EncoderNoColorContext
- Image_EncoderNoGlobalMetadata
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/3970f9087aa3aeaa.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs:405
internal readonly IntPtr CreatePixelFormatInfo()
{
IntPtr componentInfo = IntPtr.Zero;
IntPtr pixelFormatInfo = IntPtr.Zero;
using (FactoryMaker myFactory = new FactoryMaker())
{
try
{
Guid guidPixelFormat = _guidFormat;
int hr = UnsafeNativeMethods.WICImagingFactory.CreateComponentInfo(
myFactory.ImagingFactoryPtr,
ref guidPixelFormat,
out componentInfo);
if (hr == (int)WinCodecErrors.WINCODEC_ERR_COMPONENTINITIALIZEFAILURE ||
hr == (int)WinCodecErrors.WINCODEC_ERR_COMPONENTNOTFOUND)
{
throw new NotSupportedException(SR.Image_NoPixelFormatFound);
}
HRESULT.Check(hr);
Guid guidPixelFormatInfo = MILGuidData.IID_IWICPixelFormatInfo;
HRESULT.Check(UnsafeNativeMethods.MILUnknown.QueryInterface(
componentInfo,
ref guidPixelFormatInfo,
out pixelFormatInfo));
}
finally
{
if (componentInfo != IntPtr.Zero)
{
UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref componentInfo);
}
}
}
View on GitHub (pinned to 81131a70a4)