Warning: VS.Net and ImageLists on XP
-
[NB: This is not a programming question!] This problem has just had me tearing my hair out for a couple of hours, so I thought I'd share the solution. As you probably know, if you're running VS.Net on Windows XP, you can add a manifest to the "devenv.exe" file to make VS use the new XP themed controls. This looks really great, especially when you're designing a form. :) The problem starts when you add an ImageList to your form, with one or more images, of any format, colour-depth, etc., in the list. When you try to run your app, you will get the error:
Exception has been thrown by the target of an invocation.
on the line:
this.imageList1.ImageStream =
((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));It doesn't matter which language you use, the error will always occur. :( It turns out that the manifest on devenv causes the ImageList to be saved in a different format, which is not backwards-compatible with the common controls prior to v6. :mad: To solve the problem, you can either:
- on XP, define a manifest for your application; [The app still won't work on any earlier OS.]
- Remove the manifest from devenv, and re-create all of your image-lists;
Hope this saves some headaches!