Just an alternative answer that might work for some - I had this problem too (icon worked for the exe but not for the window or taskbar). Turns out it was because I had made my .ICO only include 256,48,32,16 sizes (I read that those were the only ones you needed for Windows).
After I created a new .ICO (I just included all sizes), it worked everywhere.