none
System.BadImageFormatException ?

    Question

  • First off: THANK YOU for releasing this incredible project!  I'm totally excited to put this to use.  I think you guys have really done a superior job in answering this most complex problem in application development.

    Secondly, I appear to be getting the following exception when trying to run the CTP samples:

    An unhandled exception of type 'System.BadImageFormatException' occurred in WinAppSample.exe

    Additional information: Could not load file or assembly 'System.Data.Entity, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. An attempt was made to load a program with an incorrect format.

    Funny thing is, the version of System.Data.Entity is v2.0.50727, not 2.0.0.0

    I'm running this on 2003 Server 64-bit.  I think that might be the culprit... not sure though. :)

    Just wanted to throw this out there and see if there's anything obvious I'm missing...

    Thanks, and keep up the amazing work!

    Mike

    Thursday, August 24, 2006 9:47 PM

Answers

  • Both System.Data.CTP.dll and System.Data.Entity.dll are mixed-mode assemblies (have both native and managed code in them) so they're platform-specific. For this CTP we only shipped 32-bit versions of the binaries, so you either need to run it in a 32-bit OS or you have to make your application run inside WoW64. To force the app to run in WoW64 you can go to the project properties in VS, select the "build" tab, and set the "platform target" to x86.

    Pablo Castro
    ADO.NET Technical Lead
    Microsoft Corporation

    Friday, August 25, 2006 1:30 AM

All replies

  • Both System.Data.CTP.dll and System.Data.Entity.dll are mixed-mode assemblies (have both native and managed code in them) so they're platform-specific. For this CTP we only shipped 32-bit versions of the binaries, so you either need to run it in a 32-bit OS or you have to make your application run inside WoW64. To force the app to run in WoW64 you can go to the project properties in VS, select the "build" tab, and set the "platform target" to x86.

    Pablo Castro
    ADO.NET Technical Lead
    Microsoft Corporation

    Friday, August 25, 2006 1:30 AM
  • I also had a same problem while moving the application to a server. By setting the project properties to x86 fixed the problem. Thank you
    Monday, July 21, 2008 5:34 PM
  • thanks! pablo!! your answer fixed the same issue for me!
    -Gideon MCTS:Windows Development and C# geek.
    Thursday, November 26, 2009 2:13 PM
  • Thank you so much Pablo...i changed it from x64 to x86 and it is working now...
    Friday, September 10, 2010 11:11 AM
  • Hi Pablo,

     

    I have an application which runs in 64 bit OS and with Any CPU build configuration, I call other dll which is built with x86 from my application.

    I am getting the same error, but i cannot change my application to x86 not i cannot change the dll to Any CPU, because if i change the dll to Any CPU it gives

    microsoft jet oledb 4.0 not found problem, if i change the application to x86 then it is not visible inside my biztalk piepline project, can you please guide me how

    to call a x86 build dll from any cpu build VS 2010 app?

    Wednesday, July 06, 2011 1:10 PM
  • Sorry Viv,

    Jet oledb 4 is not compatible with 64 bit apps.

    that's why you have to change to x86.

    The compiler knows it.


    Mitch Bird

    Tuesday, February 28, 2012 7:59 PM
  • Hi,

    Note that we had all our files compiled as x86, but the error remained, well, we were getting a BadImageFormat Exception.... Only after reading the first couple of lines here, the penny dropped as I remember reading somewhere that you could set the application's pool to run in 32-bit mode i.e. Enable 32-bit Applications in Advanced settings for a specific application pool. Once I changed this setting to true, it sorted my problem immediately.

    Thierry

    Monday, April 23, 2012 9:14 AM