Wednesday, December 08, 2010

vs2010 Resx Error Not Valid Win32 Application Workaround

I had a problem today compiling an app on Windows 7 64-Bit that compiled fine on XP 32 bit. It turns out that it is a bug in vs2010. This is the workaround that I used just in case you run into it.

Description
Two things were happening. Both of them were related to the resx file of my main form.
1. Images that were used in ImageList or Toolbars were causing a problem.
2. A Matrix from a class property was being cached in the resources now and causing an error.

Workaround
I reloaded the GUI images for the toolbar buttons to use images imported into the Properties Resources instead of the Form Resource. This seemed to clear up that issue.

Next, I deleted the offending Matrix data out of resx. I also removed where it was setting the class property in the InitializeComponents function. Next, I fixed the class so that the Matrix property was not serializable by the designer. So, I wouldn't have to do this again. This took a piece of metadata above the property to tell it not to set a default value:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
Everything seems to be working after that. I'll try to post the exact error next time I see it.

Happy Coding!
Jason

No comments:

Post a Comment