{"record":{"id":"3970f9087aa3aeaa","repo":"dotnet/wpf","slug":"sr-image-nopixelformatfound","errorCode":null,"errorMessage":"SR.Image_NoPixelFormatFound","messagePattern":"SR\\.Image_NoPixelFormatFound","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs","lineNumber":405,"sourceCode":"        internal readonly IntPtr CreatePixelFormatInfo()\n        {\n            IntPtr componentInfo = IntPtr.Zero;\n            IntPtr pixelFormatInfo = IntPtr.Zero;\n\n            using (FactoryMaker myFactory = new FactoryMaker())\n            {\n                try\n                {\n                    Guid guidPixelFormat = _guidFormat;\n\n                    int hr = UnsafeNativeMethods.WICImagingFactory.CreateComponentInfo(\n                        myFactory.ImagingFactoryPtr,\n                        ref guidPixelFormat,\n                        out componentInfo);\n                    if (hr == (int)WinCodecErrors.WINCODEC_ERR_COMPONENTINITIALIZEFAILURE ||\n                        hr == (int)WinCodecErrors.WINCODEC_ERR_COMPONENTNOTFOUND)\n                    {\n                        throw new NotSupportedException(SR.Image_NoPixelFormatFound);\n                    }\n                    HRESULT.Check(hr);\n\n                    Guid guidPixelFormatInfo = MILGuidData.IID_IWICPixelFormatInfo;\n                    HRESULT.Check(UnsafeNativeMethods.MILUnknown.QueryInterface(\n                        componentInfo,\n                        ref guidPixelFormatInfo,\n                        out pixelFormatInfo));\n                }\n                finally\n                {\n                    if (componentInfo != IntPtr.Zero)\n                    {\n                        UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref componentInfo);\n                    }\n                }\n            }\n","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PixelFormat.cs#L387-L423","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nvar info = GetPixelFormatInfo(pixelFormat); // may throw for Extended\n// after\nif (pixelFormat == PixelFormats.Extended) return DefaultPixelFormatInfo();\ntry { return GetPixelFormatInfo(pixelFormat); }\ncatch (NotSupportedException) { return DefaultPixelFormatInfo(); }","handlingStrategy":"try-catch","validationCode":"if (pixelFormat == PixelFormats.Extended) throw new SkipPixelFormatInfoException();","typeGuard":"bool IsWicBackedFormat(PixelFormat pf) => pf != PixelFormats.Default && pf != PixelFormats.Extended;","tryCatchPattern":"try { return CreatePixelFormatInfo(pf); }\ncatch (NotSupportedException ex) { log(ex); return FallbackPixelFormatInfo(pf); }","preventionTips":["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"],"tags":["wpf","wic","pixelformat","imaging"],"backgroundTag":"unsupported-operation","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"}