Resource file .resx compile error in 64-bit Windows 7

2011-05-04


We have a project which can be built on Windows XP and Windows 7 32-bit, But when we moved it to a Windows 7 64-bit PC, We got the following compile error in Visual Studio 2010:

could not load file or assembly 'XXXXX.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. Line 219, position 5. xxxxx.resx

When double click this error, Visual Studio will open the .resx file like following:

This issue seems be the bug of Visual Studio 2010, it ONLY occur on the 64-bit Widnows 7 or Vista if you use your Visual Studio 2010.

People had discussions about this bug on here.

So the most simple work around is: Make the assembly you’re referencing AnyCPU rather than being architecture-specific.

However, sometimes the referencing assembly is from 3rd party, you can not modify it.

So, another work around is:

  1. Double-click resx compile error to open resx file. Scroll to top ;

  2. Edit the top line of the stream:

AAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0 TO AAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0yLjAuMC4wLCBDdWx0

( *NOTE: the only difference are the characters at end "j00LjAuMC4wLCBDdWx0' to "j0yLjAuMC4wLCBDdWx0 )

  1. save resx file and recompile.