Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: "System.BadImageFormatException" in sfmlnet-graphics-2.dll  (Read 2102 times)

0 Members and 1 Guest are viewing this topic.

CssHammer

  • Newbie
  • *
  • Posts: 18
    • View Profile
"System.BadImageFormatException" in sfmlnet-graphics-2.dll
« on: November 28, 2014, 07:08:04 pm »
Exception happens when I compile my project. Image is too long >> ( http://cs621523.vk.me/v621523284/1ab1/9Gdogk6th1I.jpg )
sfml .dlls grabbed from lastest GitHub update, csfml .dlls taken from http://www.nightlybuilds.ch/files/download/161/CSFML-Visual%20Studio-2013-32.7z

CssHammer

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: "System.BadImageFormatException" in sfmlnet-graphics-2.dll
« Reply #1 on: December 05, 2014, 05:17:25 pm »
Can anyone help?

Ztormi

  • Jr. Member
  • **
  • Posts: 71
  • Web developer by day. Game developer by night.
    • View Profile
Re: "System.BadImageFormatException" in sfmlnet-graphics-2.dll
« Reply #2 on: December 05, 2014, 06:48:02 pm »
Try changing project's target platform to x86/x64.
« Last Edit: December 05, 2014, 06:49:37 pm by Ztormi »

CssHammer

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: "System.BadImageFormatException" in sfmlnet-graphics-2.dll
« Reply #3 on: December 06, 2014, 09:54:51 pm »
It doesn`t help

windsorperma

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: "System.BadImageFormatException" in sfmlnet-graphics-2.dll
« Reply #4 on: December 09, 2020, 08:07:34 am »
The exception that is thrown when the file image of a dynamic link library (DLL) or an executable program is invalid. If you get a BadImageFormatException when interfacing with a native DLL, it almost always means that you are trying to interface with a 32-bit DLL while running in the 64-bit CLR, or vice versa. In most cases you might be  facing the problem with your website after deploying on server.

Make sure that you are not having 32-bit / 64-bit conflict. So, you need to adjust your application pool to Enable 32-Bit  or 64-Bit accordingly. Set the Target platform setting on your c# EXE project, not your class library project. Alternatively, you can ship both 32-bit and 64-bit DLLs with different file names, define separate P/Invoke stubs for each version, and decide which one to call at runtime. The easiest way to do this would probably be to wrap your native calls in an interface (e.g., INativeMethods) and choose which implementation to instantiate at runtime based on IntPtr.Size. With this method, you could still target AnyCPU.

 

anything