Error with the icon of my app in XP

I've done two apps in Win7 x64 with VS2012, but when I try to run it in XP I was getting an unknown error when trying to open the apps.

Finally I found the problem and is in this line generated by the designer in the Main.Designer.vb:

Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)

(If I delete the line then all is OK in XP)

I always select the TitleBar icon by clicking on the "Icon" property field in the form properties.

I have some questions about this...

  1. How I can modify that line to still showing my icon and working in XP?

  2. Everytime that I put an Icon to the titlebar of my form then I need to manually modify that line to work in XP?

  3. Why Microsoft is so silly to make incompatible with XP it's own generated code of the designer? (don't need to answer this)


  • You can set the form icon at runtime to try and get round this.

    • Add an icon your your project resources call it ApplicationIcon

    • In Form_Load add:

    • Me.Icon = My.Resources.ApplicationIcon