{"record":{"id":"9663f9d6dc154607","repo":"wailsapp/wails","slug":"missing-icon-with-icon-id-d","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/buttons.go","lineNumber":63,"sourceCode":"func (bt *Button) SetChecked(checked bool) {\n\twparam := w32.BST_CHECKED\n\tif !checked {\n\t\twparam = w32.BST_UNCHECKED\n\t}\n\tw32.SendMessage(bt.hwnd, w32.BM_SETCHECK, uintptr(wparam), 0)\n}\n\n// SetIcon sets icon on the button. Recommended icons are 32x32 with 32bit color depth.\nfunc (bt *Button) SetIcon(ico *Icon) {\n\tw32.SendMessage(bt.hwnd, w32.BM_SETIMAGE, w32.IMAGE_ICON, uintptr(ico.handle))\n}\n\nfunc (bt *Button) SetResIcon(iconID uint16) {\n\tif ico, err := NewIconFromResource(GetAppInstance(), iconID); err == nil {\n\t\tbt.SetIcon(ico)\n\t\treturn\n\t}\n\tpanic(fmt.Sprintf(\"missing icon with icon ID: %d\", iconID))\n}\n\ntype PushButton struct {\n\tButton\n}\n\nfunc NewPushButton(parent Controller) *PushButton {\n\tpb := new(PushButton)\n\n\tpb.InitControl(\"BUTTON\", parent, 0, w32.BS_PUSHBUTTON|w32.WS_TABSTOP|w32.WS_VISIBLE|w32.WS_CHILD)\n\tRegMsgHandler(pb)\n\n\tpb.SetFont(DefaultFont)\n\tpb.SetText(\"Button\")\n\tpb.SetSize(100, 22)\n\n\treturn pb\n}","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v2/internal/frontend/desktop/windows/winc/buttons.go#L45-L81","documentation":"Button.SetResIcon tries to load an icon by numeric resource ID from the executable's resources via NewIconFromResource(GetAppInstance(), iconID); if the lookup fails it panics with the missing ID. This means the .exe (or the module returned by GetAppInstance) has no icon resource with that numeric ID — common when resources live in a linked .syso/.rc file that was not built in, or the ID was taken from a header that does not match the compiled resource script.","triggerScenarios":"Calling button.SetResIcon(n) where n is not defined as an ICON resource in the application's .rc/.syso; IDs shifted because the .rc auto-numbering (or a resource header like resource.h) changed; the resource was embedded as a string name instead of a numeric ID.","commonSituations":"Wails v2 Windows apps embedding icons via windres/go-winres .syso files where the generated IDs don't match; porting WinForms-style code that used MAKEINTRESOURCE IDs from a different project; CI builds stripping resources.","solutions":["Inspect the built executable's resources (Resource Hacker, or `windres`/`go-winres` dump) and confirm an icon exists with the exact numeric ID passed to SetResIcon","Keep resource IDs in a single shared resource.h and regenerate the .syso whenever IDs change: `go-winres simply --icon-id=<id>` (or windres) then rebuild","Load icons by file path or embedded bytes instead (NewIconFromResource is module-based): use image.NewIconFromFile / embed the icon and create it from an HICON you control","Guard with a runtime lookup before calling SetResIcon (see validation code) so a missing icon degrades gracefully instead of panicking"],"exampleFix":"// before\nbtn.SetResIcon(101) // panics if exe has no icon resource 101\n\n// after\nif _, err := winc.NewIconFromResource(winc.GetAppInstance(), 101); err == nil {\n    btn.SetResIcon(101)\n} else {\n    ico, _ := winc.NewIconFromFile(\"assets/button.ico\")\n    if ico != nil { btn.SetIcon(ico) }\n}","handlingStrategy":"validation","validationCode":"func resIconExists(id uint16) bool {\n    _, err := winc.NewIconFromResource(winc.GetAppInstance(), id)\n    return err == nil\n}\n\nif resIconExists(101) {\n    btn.SetResIcon(101)\n} else {\n    if ico, err := winc.NewIconFromFile(\"assets/fallback.ico\"); err == nil {\n        btn.SetIcon(ico)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep resource IDs in one generated header; regenerate the .syso whenever icons change","Verify embedded icons in CI by dumping resources from the built exe","Prefer SetIcon with a loaded Icon over SetResIcon for app-owned assets"],"tags":["windows","resources","icon","winc","panic","build-config"],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}