ASP.NET: System.BadImageFormatException: An attempt was made to load a program with an incorrect for

來源:互聯網
上載者:User

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].

以上參考:http://www.lazyasscoder.com/Article.aspx?id=90&title=System.BadImageFormatException%3A+An+attempt+was+made+to+load+a+program+with+an+incorrect+format.++on+Win2k8+64bit%2C+IIS7%2C+Oracle

 

My .NET web service used to live in a 32-bit Windows 2003 server running under IIS6 connecting to an Oracle database.  I had to migrate my web service to a new 64-bit Windows 2008 server running IIS7.  This is when the following error started:

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.

  1. Right clicked over the AppPool name 
  2. Selected Advanced Settings...
  3. Under the General Section, set Enable 32-Bits Application to True
  4. Click OK, you may want to recycle the application pool just to be sure.

Done, nice and simple. No code changes required.

 

貼圖:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.