How to fix a .resx file that won't compile for .Net 3.5
According to a thread on Microsoft's site, there is a problem compiling some .resx files in .Net 3.5 projects with Visual Studio 2010 and for x86 processors.
The compile error may look like :
Description | File | Line | Column | Project | ||
---|---|---|---|---|---|---|
Error | 1 | Could not load file or assembly 'file:///C:/xyz.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. Line 1974, position 5. | C:\Form1.resx | 1974 | 5 | XYZ |
The line and column refer to the close of the data tag for an ImageStream data value.
<data name="ilsButtons.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
BlahBlahBlahBlahBlah…
Ad8BvwG6Af8BygG8AbYB/wHEAcABuwH/AcEBwgG+Af8BQgFNAT4HAAE+AwABKAMAAWgBAQIAAUIDAAEB
AQABAQUAAWABDBYAA///AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wBtAAs=
</value>
</data>
The solutions offered up have included compiling for AnyCPU instead of for x86. I cannot compile this form for AnyCPU since it contains an ActiveX control that will not run on a 64bit machine if compiled for AnyCPU.
There is also a suggestion to upgrade the projects to .Net 4.0. If that is a less than desirable outcome for you, and you just need a quick fix, the thread also includes a quick fix to the data in the .resx file. This fix will have to be made every time the IDE modifies the .resx file (which is every time you open the form for graphical editing in the IDE). Since this form is rarely being modified anymore, and all we are really working on is bug fixes in other areas of the project, this solution seems more ideal for us than changing installation requirements for the whole project.
The solution comes from Pellet21 on 2/24/2011. He says to edit the top line of the ImageStream value in the .resx file. Change it from
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4wto
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4wThat's simply changing the 9th character from the right from a zero to the lower case letter y. Once you make that change, the project will compile. Just don't open up the form for graphical editing in the IDE again… unless you want to change that character again.