Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format

后端 未结 10 1497
轮回少年
轮回少年 2021-01-31 11:49

I have installed a Web app on IIS 7.0 Windows Server 2008 R2 64bit. I am referring an oracle.DataAccess.dll; When I try to access the application I get the following message: \"

10条回答
  •  情书的邮戳
    2021-01-31 12:11

    Yeah, it is a quite annoying issue I faced sometimes. The main problem is that an web application uses wrongly 32 bit Oracle.DataAccess.dll instead of 64 bit, or in the reverse case. There are a few solutions for it.

    1. Enabling 32-bit applications in the application pool if your application is 64 bit and need to run 32 bit Oracle.DataAccess.dll.

    Go to the IIS and set true for "Enable 32-Bit Applications" option in Advanced Settings of an Application pool.

    2. Correcting reference dll.

    Reference path is supposed to be system reference path configured by Oracle Installation process. But, some cases such as installing or updating new Oracle version, the latest DLLs doesn't update old ones, or path is changed, or a reference is not updated in the web application project. Therefore, we should correct Oracle.DataAccess reference manually.

    Go to the web application and remove Oracle.DataAccess reference. And add new reference for Oracle.DataAccess. It must be correct Oracle.DataAccess.dll from your oracle installation path. For example:

    C:\Oracle\product\12.2.0\client_1\odp.net\bin\4\Oracle.DataAccess.dll

    ODP.NET and Dependent Unmanaged DLL Mismatch To enforce the usage of Oracle.DataAccess.dll assembly with the correct version of its unmanaged DLLs, an exception is raised if Oracle.DataAccess.dll notices it has loaded a mismatched version of a dependent unmanaged DLL.

    https://docs.oracle.com/cd/E11882_01/win.112/e23174/InstallODP.htm#ODPNT152

    3. Easy and quick way (but not proper solution) to fix the issue is that override directly an Oracle.DataAccess.dll file copying from oracle installation path (for example: C:\Oracle\product\12.2.0\client_1\odp.net\bin\4\ ) to Bin folder of your web application.

    Hope this helps you a little. Good luck.

提交回复
热议问题