{"record":{"id":"6d5b827e870054d8","repo":"wailsapp/wails","slug":"missing-icon-with-icon-id-d-6d5b82","errorCode":null,"errorMessage":"missing icon with icon ID: %d","messagePattern":"missing icon with icon ID: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v2/internal/frontend/desktop/windows/winc/imagelist.go","lineNumber":55,"sourceCode":"\nfunc (im *ImageList) SetImageCount(uNewCount uint) bool {\n\treturn w32.ImageList_SetImageCount(im.handle, uNewCount)\n}\n\nfunc (im *ImageList) ImageCount() int {\n\treturn w32.ImageList_GetImageCount(im.handle)\n}\n\nfunc (im *ImageList) AddIcon(icon *Icon) int {\n\treturn w32.ImageList_AddIcon(im.handle, icon.Handle())\n}\n\nfunc (im *ImageList) AddResIcon(iconID uint16) {\n\tif ico, err := NewIconFromResource(GetAppInstance(), iconID); err == nil {\n\t\tim.AddIcon(ico)\n\t\treturn\n\t}\n\tpanic(fmt.Sprintf(\"missing icon with icon ID: %d\", iconID))\n}\n\nfunc (im *ImageList) RemoveAll() bool {\n\treturn w32.ImageList_RemoveAll(im.handle)\n}\n\nfunc (im *ImageList) Remove(i int) bool {\n\treturn w32.ImageList_Remove(im.handle, i)\n}\n","sourceCodeStart":37,"sourceCodeEnd":65,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v2/internal/frontend/desktop/windows/winc/imagelist.go#L37-L65","documentation":"ImageList.AddResIcon loads an icon by numeric resource ID from the executable via NewIconFromResource(GetAppInstance(), iconID) and panics when the load fails, mirroring Button.SetResIcon. The panic means the module returned by GetAppInstance has no icon resource with that numeric ID — the .syso/.rc resources baked into the binary don't contain it (or contain it under a different ID/name).","triggerScenarios":"Calling iml.AddResIcon(n) where n is absent from the exe's resources; resource IDs shifted after regenerating the .rc/.syso; icons embedded under string names rather than numeric IDs; adding the icon to an image list for a ListView/TreeView toolbar at startup.","commonSituations":"Wails v2 Windows builds using go-winres/windres .syso files whose icon IDs drift from constants in code; SVI/tree controls populated from shell32-style IDs that were never embedded in this exe.","solutions":["Dump the exe's resources (Resource Hacker / go-winres) and align the numeric ID passed to AddResIcon with an actually embedded icon","Centralize resource IDs in one generated header and regenerate the .syso whenever icons change","Prefer loading icons you ship (NewIconFromFile / embedded bytes -> HICON) and use iml.AddIcon(ico) instead of resource IDs","Validate availability first (see validation code) and degrade to a default icon rather than crashing"],"exampleFix":"// before\niml.AddResIcon(101) // panics when exe lacks icon resource 101\n\n// after\nif ico, err := winc.NewIconFromResource(winc.GetAppInstance(), 101); err == nil {\n    iml.AddIcon(ico)\n} else if d, err2 := winc.NewIconFromFile(\"assets/item.ico\"); err2 == nil {\n    iml.AddIcon(d)\n}","handlingStrategy":"validation","validationCode":"func addResIconSafe(iml *winc.ImageList, id uint16) bool {\n    if ico, err := winc.NewIconFromResource(winc.GetAppInstance(), id); err == nil {\n        iml.AddIcon(ico)\n        return true\n    }\n    if d, err := winc.NewIconFromFile(\"assets/default.ico\"); err == nil {\n        iml.AddIcon(d)\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Align resource IDs between the .rc/.syso and code via one generated header","Prefer AddIcon with icons you load yourself over numeric resource IDs","Dump exe resources in CI to verify embedded icon IDs"],"tags":["windows","resources","icon","imagelist","winc","panic","build-config"],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}