How to fix BadImageFormatException on application startup?


I bought the game Stardew Valley on steam, installed it, launched it. Nothing happened :(...
When I took a look in the eventviewer I saw the following information:

Application: Stardew Valley.exe Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.BadImageFormatException    at

To me this sounds like a bad dll or a wrong architecture for a dll, but I haven't been able to sort out what the problem is. Right after that:

Faulting application name: Stardew Valley.exe, version: 1.0.5940.30711, time stamp: 0x5705b1ef
Faulting module name: KERNELBASE.dll, version: 10.0.10586.162, time stamp: 0x56cd55ab
Exception code: 0xe0434352
Fault offset: 0x000bdad8
Faulting process id: 0x23d8
Faulting application start time: 0x01d19eee1ec0b80d
Faulting application path: F:\Steam\steamapps\common\Stardew Valley\Stardew Valley.exe
Faulting module path: C:\WINDOWS\SYSTEM32\KERNELBASE.dll
Report Id: b8cdbcca-597d-4eb4-a44c-47f2b8c510a5
Faulting package full name: 
Faulting package-relative application ID: 

Followed by:

Fault bucket 108078241334, type 1
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: Stardew Valley.exe
P2: 1.0.5940.30711
P3: 5705b1ef
P5: 10.0.10586.162
P6: 56cd55ab
P7: e0434352
P8: 000bdad8

I like to fix my own problems, but after 6 hours I give up. I used Dependency Walker to inform me about missing dll's or incompatible versions. One of the strange things is that the game exe is x86 and all loaded dll's are x64. My wife also has the game and it works on her machine, however Dependency Walker reported no big differences. She only got a few more dll's available (which I copied afterwards, but didn't help).

Here is what I tried (with reboots in between):

  • Reinstall game (3 times)
  • Reboot
  • Steam file integrity check
  • Start outside steam
  • Start as administrator
  • All compatibility modes
  • Reinstalling XNA 4.0
  • Completely removed XNA 4.0 and reinstall
  • sfc /scannow
  • dism /Online /Cleanup-Image /RestoreHealth
  • Installing on game on C drive instead of F drive
  • Complete removal of all System32/d2*.dll and d3*.dll and reinstalling directx (Which broke a few other games)
  • Updated graphic drivers
  • dxdiag reports no problems
  • shut down and turning on again
  • placing the following (missing) dll's in the system32/syswow64/game directory
    • (x86)API-MS-WIN-CORE-FIBERS-L1-1-1.DLL
    • (x86)API-MS-WIN-CORE-FIBERS-L2-1-1.DLL
    • (x86)API-MS-WIN-MM-MISC-L1-1-1.DLL
    • (x86)IESHIMS.DLL
    • (x64)API-MS-WIN-BASE-UTIL-L1-1-0.DLL
    • (x64)API-MS-WIN-CORE-COMM-L1-1-0.DLL

I decompiled the exe to look at its references, which are:

  • Lidgren.Network
  • Microsoft.Xna.Framework
  • Microsoft.Xna.Framework.Game
  • Microsoft.Xna.Framework.Graphics
  • Microsoft.Xna.Framework.Xact
  • mscorlib
  • PresentationCore
  • Steamworks.NET
  • System
  • System.Core
  • System.ServiceModel
  • System.Windows.Forms
  • System.Xml
  • xTile

All these dll's were succesfully resolved.
What more can I do to try to fix this issue? I will reinstall my system in two months from now, which might help, but I think it is too radical to do it now for the sake of 1 program that refuses to launch.

Here is a crash dump which will expire on 27-04-2016.

I also looked into the crash dump and tried to debug it with Visual Studio 2015. I'm getting the following error: An unhandled exception of type 'System.BadImageFormatException' occurred in Unknown Module.

Additional information: Could not load file or assembly 'Microsoft.Xna.Framework.dll' or one of its dependencies.  is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

If there is a handler for this exception, the program may be safely continued.

I do not understand this error. I already reinstalled it twice!
However, when I search for the dll, I find multiple version located at the following places:

  • C:\Program Files (x86)\Microsoft Silverlight\5.1.41212.0
  • C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\MDILXAPCompile\Framework
  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.1
  • C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\AppDeploy\MdilXapCompilev8.0\Framework
  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0
  • C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86
  • C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Xbox360
  • C:\Windows\Microsoft.NET\assembly\GAC_32\Microsoft.Xna.Framework\v4.0_4.0.0.0__842cf8be1de50553

When I look at the references with DotPeek it says it takes this one: C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.dll (which exists).

asked on Super User Apr 25, 2016 by Mixxiphoid • edited Apr 25, 2016 by Mixxiphoid

3 Answers


I finally fixed it. Here is the solution:

I had the x64 X3dAudio_7.dll in the sysWow64 folder and the x86 X3dAudio_7.dll in the system32 folder. I switched them, reinstalled XNA and everything worked!

I found this out by opening Microsoft.Xna.Framework.dll in Dependency Walker. I noticed that all refered DLL's were x64 except for this one.

It may not seem logical but, if you have a x64 installation of windows, all x64 dll's go into the system32 folder and the x86 dll's into the SysWow64 folder.

answered on Super User Apr 25, 2016 by Mixxiphoid

I was going to just add a comment but can't yet, and this is unlikely to work anyway, but it's worth a shot since you probably haven't tried it.

You might want to uninstall the game before doing this, but it's up to you really as you seem to have a pretty decent grasp on this stuff anyway.

With Steam closed

1) Start > Run > %temp% (clear all that junk out)

2) Clear out the temporary files in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files and C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files

3) Run the .NET repair utility (and possibly update .NET to the latest stable version which might be 4.6.2):

Then maybe reboot and try again, or reinstall the game if you removed it before doing that stuff.

Edit: and all of that stuff you've uninstalled/reinstalled, did you install both the x64 and x86 versions?

Also seems to be some relevant discussions here

answered on Super User Apr 25, 2016 by pay • edited Apr 25, 2016 by pay

or you can put the 32bit version of X3dAudio_7.dll into the same folder of the game exe.

answered on Super User Jul 12, 2018 by pitsch

User contributions licensed under CC BY-SA 3.0