Tools to diagnose BadImageFormatException thrown for System.Data assembly in production?

0

I'm getting following exception on a production machine for a Windows desktop app:

Could not load file or assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. File is corrupt. (Exception from HRESULT: 0x8013110E)

I understand there can be multiple reasons like platform mismatch, targeted .net framework mismatch, etc. But, what tools/checks can I run on production machine to pin-point the cause?

c#
.net
clr
desktop-application
asked on Stack Overflow May 30, 2013 by Karan • edited May 30, 2013 by Karan

1 Answer

0

The fact is that the app is in 64-bits. So look into that and find an option in the advanced settings of an app pool in IIS7, named "Enable 32-Bit Applications". enter image description here

After setting it to true, everything will normally work.

Note: If you want to use this in IIS6, be aware that IIS6 does not support this on a "per app pool" basis. So if you set IIS6 to 32 bit, all its app pools will run in 32 bit mode. If you want to set this on a "per app pool" basis, you will have to upgrade to IIS7. To set IIS6 to 32 bit, do the following:

  1. Open a command prompt and navigate to the %systemdrive%\Inetpub\AdminScripts directory.
  2. Enter the following command:

cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 "true" It seems that in some cases, the "true" from the above command needs to be replaced with a 1. Sometimes it is also necessary to reset IIS.

answered on Stack Overflow May 30, 2013 by h.meknassi

User contributions licensed under CC BY-SA 3.0