Calling unmanaged 32bit DLL exception occuring only on one user's computer: BadImageFormatException (Exception from HRESULT: 0x8007000B)

0

Our application is C# .Net 4 and calls an unmanaged 32bit DLL. It's been working fine and runs many machines (mostly 64bit Windows 7). However, I recently encountered one particular user on whose machine the program traps with BadImageFormatException as soon as the call into the unmanaged DLL is made.

BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

I've done the following:

  1. Ensured the install and files are correct
  2. Matched his .Net runtime updates as closely as possible to working machines
  3. Ensured all projects' platform target are set to x86
  4. Run a debug build, which works

I'm nearing my wit's end. Any suggestions? Is there a particular .Net 4 update or hotfix the lack of which cause this type of issue?

dll
unmanaged
32-bit
hresult
badimageformatexception
asked on Stack Overflow Jan 12, 2013 by fred • edited Dec 18, 2019 by Bob Gilmore

1 Answer

0

The problem turns out to be some misplaced/invalid system files on the user's machine, which can manifest as "The Application was unable to start correctly (0xc000007b). Click OK to close the application" when starting certain applications.

The problem was due to 32/64-bit mismatches of various system dlls required by Visual studio. Somehow the dlls it needs got replaced by 64-bit versions that it couldn’t load.

Replacing the dlls mentioned below from a machine that is working solves the problem:

c:\Windows\SysWOW64\msvcp100.dll c:\Windows\SysWOW64\msvcp100d.dll c:\Windows\SysWOW64\msvcr100.dll c:\Windows\SysWOW64\msvcr100_clr0400.dll c:\Windows\SysWOW64\msvcr100d.dll

http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/96035692-9a50-40d4-a7d3-48bda87d11ec

answered on Stack Overflow Jan 18, 2013 by fred

User contributions licensed under CC BY-SA 3.0