ASP.NET: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. on Win7 64bit
These message as blow:
Server Error in '/WebService' Application.
--------------------------------------------------------------------------------
Could not load file or assembly '******' or one of its dependencies. An attempt was made to load a program with an
incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'DHI.DHIfl' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and
location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'DHI.DHIfl' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at Oracle.DataAccess.Client.OpsTrace.GetRegTraceInfo(UInt32& TrcLevel)
at Oracle.DataAccess.Client.OraTrace.GetRegistryTraceInfo()
at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString)
What the hell does this error means, no body knows. After alot of googling and playing around on the server with IIS, I finally figured out the solution to my problem.
Because my web service application was using an older 32-bit Oracle driver, I had to force IIS7 to run in 32-bit mode and this is how I did it.
Under IIS7, my web application was running in an application pool.
- Right clicked over the AppPool name
- Selected Advanced Settings...
- Under the General Section, set Enable 32-Bits Application to True
- Click OK, you may want to recycle the application pool just to be sure.
贴图: