1

I am referencing to an assembly built on .net 2.0 in .net 3.5 project. Its working fine on Windows xp machine, but when deploying on Win2003 64 bit

I am getting error below

System.BadImageFormatException: Could not load file or assembly 'Wrapper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Project is built on Win xp 32 bit machine and then deployed using wix installer, Tried manually replacing assembly but didn't work.

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Rajnikant
  • 2,176
  • 24
  • 23
  • Possible duplicate: http://stackoverflow.com/questions/7325660/cannot-load-assembly-problem – Rik Dec 06 '12 at 13:59

1 Answers1

2

You should check the build properties of the Wrapper assembly. I suspect it's set to 32-bit (x86). You'll need it to either be AnyCpu or x64 in order to be loaded into a 64-bit CLR.

Now if it's actually a wrapper for unmanaged code, you probably want two different versions of the assembly - one for 32-bit and one for 64-bit.

Another alternative is to change your application to be 32-bit. It's not clear what kind of application you're running, or whether that would be suitable - but it's worth considering.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Hi John, There is no problem running it on 32 bit system. So I believe the assembly is 32 bit version. – Rajnikant Dec 06 '12 at 14:28
  • @RAJ: Don't just "believe" it - *check* it. Look at the file, e.g. with ildasm, checking `.corflags` in the metadata section. – Jon Skeet Dec 06 '12 at 14:33
  • Figured out problem, used corflags.exe to find the header, – Rajnikant Dec 06 '12 at 15:53
  • Figured out problem, Assemly I am referencing is PE32. When I compiled executing assembly on 32bit system and copy it over DEV box (Server 2003 64 bit) its working fine. I am using TeamCity and build machine is also 64 bit, so executing assembly was compiled on 64 bit system and /platform option is anycpu. Now I need suggestion what the is best way to solve it. – Rajnikant Dec 06 '12 at 16:11
  • @RAJ: Change the /platform option on the *executable* to x86 (32-bit) and it should then use the 32-bit CLR. – Jon Skeet Dec 06 '12 at 16:12