Getting BadImageFormatException in 64-bit Windows?
17 January 2008 in .NET in general & Code-ing | Comments enabled

Have you been running/developing .NET programs in 64-bit Windows and met the BadImageFormatException? Well, Microsoft might say: “The exception that is thrown when the file image of a DLL or an executable program is invalid.” Which says absolutely nothing… :)

However, if it happens when using Platform Invove (P/Invoke or DllImport) or a third .NET party library (DLL) then you might have to set the project’s properties (or compilation flags) from “any” platform target to “x86″. Also, remember to set change to x86 in both the debug and release build configurations while you are at it, otherwise it might seem to only work when you are debugging and not in release compilation.

(This happened to me when I used a .NET code library for a LabJack device in a program and ran the program under 64-bit Vista. Couldn’t find what the nature of the problem “really” was… )

3 comments. Add your own comment.

JS says 12 June 2008 @ 22:24

Thanks! It fixed the problem.

frenchfaso says 27 October 2008 @ 23:53

OhHo! You’re the man…
thank You so much, I could’nt compile examples of Brahma (http://brahma.ananthonline.net) until I read your post.

Paulie says 6 November 2008 @ 18:07

Worked for me too. Cheers

Leave a Comment

Name

E-mail (not published)

Website

Your comment:

Powered by WP Hashcash


  •  

    January 2008
    M T W T F S S
    « Dec   Mar »
     123456
    78910111213
    14151617181920
    21222324252627
    28293031  
  • Categories