{"record":{"id":"511f9dcdc916f4ac","repo":"SixLabors/ImageSharp","slug":"the-icon-file-does-not-contain-any-decodable-image-entries","errorCode":null,"errorMessage":"The icon file does not contain any decodable image entries.","messagePattern":"The icon file does not contain any decodable image entries\\.","errorType":"exception","errorClass":"InvalidImageContentException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Icon/IconDecoderCore.cs","lineNumber":78,"sourceCode":"                    Span<byte> flag = this.buffer[..PngConstants.HeaderBytes.Length];\n                    CheckEndOfStream(frameStream.Read(flag), flag.Length);\n                    frameStream.Position = 0;\n\n                    bool isPng = flag.SequenceEqual(PngConstants.HeaderBytes);\n                    IconFrameCompression compression = isPng ? IconFrameCompression.Png : IconFrameCompression.Bmp;\n\n                    // Frames remain alive until the largest decoded dimensions are known and the common canvas can be allocated.\n                    Image<TPixel> decoded = this.GetDecoder(isPng).Decode<TPixel>(this.Options.Configuration, frameStream, cancellationToken);\n                    decodedEntries[decodedCount++] = (entryIndex, decoded, compression);\n\n                    // The embedded header is authoritative because a zero directory dimension can represent 256 pixels or a larger Vista-era PNG.\n                    this.Dimensions = new Size(Math.Max(this.Dimensions.Width, decoded.Width), Math.Max(this.Dimensions.Height, decoded.Height));\n                });\n            }\n\n            if (decodedCount is 0)\n            {\n                throw new InvalidImageContentException(\"The icon file does not contain any decodable image entries.\");\n            }\n\n            // General profiles belong to the icon result even though the first successfully decoded child image is temporary.\n            ImageMetadata metadata = decodedEntries[0].Image.Metadata.DeepClone();\n            BmpMetadata? bmpMetadata = null;\n            PngMetadata? pngMetadata = null;\n            ImageFrame<TPixel>[] frames = new ImageFrame<TPixel>[decodedCount];\n            int initializedFrameCount = 0;\n\n            try\n            {\n                for (int i = 0; i < decodedCount; i++)\n                {\n                    BmpBitsPerPixel bitsPerPixel = BmpBitsPerPixel.Bit32;\n                    ReadOnlyMemory<Color>? colorTable = null;\n                    Image<TPixel> decoded = decodedEntries[i].Image;\n                    ref IconDirEntry entry = ref this.entries[decodedEntries[i].EntryIndex];\n                    ImageFrame<TPixel> source = decoded.Frames.RootFrameUnsafe;","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Icon/IconDecoderCore.cs#L60-L96","documentation":"Thrown during icon decoding when the directory lists entries but none of the child images (PNG or BMP payloads) could actually be decoded, so no image data is available to build the result. SixLabors.ImageSharp throws InvalidImageContentException because the container is structurally present but contains no usable image payloads.","triggerScenarios":"Calling Image.Load/Decode on an ICO/CUR whose directory entries all fail child decoding — e.g. every entry's payload is corrupt, zero-length after range validation, or uses an unsupported inner format.","commonSituations":"Malformed ICO files produced by buggy converters; icons whose embedded PNG/BMP payloads are damaged; files renamed to .ico that are not real icon resources; truncated icon payloads after BytesInRes clamping.","solutions":["Verify each embedded entry decodes standalone (extract the payload at ImageOffset with BytesInRes length and load it as PNG/BMP)","Re-export the icon with a known-good tool (e.g. icoconvert, ImageMagick) or from original assets","Catch InvalidImageContentException and fall back to a placeholder icon","Check the file is genuinely an ICO/CUR and not a renamed PNG/other format"],"exampleFix":"// before\nvar image = Image.Load(\"app.ico\");\n// after\ntry\n{\n    var image = Image.Load(\"app.ico\");\n}\ncatch (InvalidImageContentException)\n{\n    // no decodable child entries in the icon\n    image = null; // use fallback asset\n}","handlingStrategy":"try-catch","validationCode":"// basic ICO sanity: ICONDIR present with at least one entry\nstatic bool LooksLikeNonEmptyIco(string path)\n{\n    var b = File.ReadAllBytes(path);\n    return b.Length >= 22 && b[0] == 0 && b[1] == 0 && b[2] is 1 or 2 && b[4] | (b[5] << 8) > 0;\n}","typeGuard":"static bool IsInvalidImageContent(Exception ex) => ex is InvalidImageContentException;","tryCatchPattern":"try\n{\n    var image = Image.Load(icoPath);\n}\ncatch (InvalidImageContentException)\n{\n    // no decodable entries: use a fallback icon\n    image = LoadFallbackIcon();\n}","preventionTips":["Obtain icons from trusted generators","Pre-validate entry offsets/sizes before loading untrusted icons","Always keep a fallback icon asset in the app"],"tags":["icon","ico","invalid-image-content","corrupt-file"],"backgroundTag":"invalid-image-content","analyzedSha":"59ce6af6fc29027cda277ef62d4d1694a8acce91","analyzedAt":"2026-09-13T18:34:59.331Z","contentChangedAt":"2026-09-13T18:34:59.331Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}