Here is a fix for an error that I received in Visual Studio 2010
The error reads:
Could not load file or assembly ‘file:/// [path to assembly]’ or one of its dependencies. An attempt was made to load a program with an incorrect format. Line 465, position 5.
To fix the problem, I did this:
- Double-click the error (which was located in the VS2010 Error List Window)
- After double-clicking the error, the cursor will be placed in an XML closing tag called </data>. From the closing </data> tag, scroll to the opening <data> tag. The <data> tag contents looked like this:
<data name="imageList.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64"> <value> AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
- Manually make a change to a part of the string exactly as follows: Change the end of the string from
j00LjAuMC4w to j0yLjAuMC4w
Note that the only change is swapping out the second zero with a ‘y’
- Rebuild the Visual Studio Solution
Notice! The stream data that you edited was derived from an ImageList that exists in your assembly. So, each and every time you make a change to the ImageList or open the Windows Form (that contains the ImageList) in Designer Mode, you will need to do the above procedure.
This problem occurs when your development machine is running a 64bit OS (I was running Windows Server 2008 RS 64bit). Apparently, what’s happening is Visual Studio is serializing ImageLists with a reference to .NET 4.0 instead of .NET 2. This information is specifically defined at the “j00” section of the serialized data. Changing the data to “j0y” informs ResGen.exe that the ImageList targets .NET 2.