Could not load file or assembly 'Oracle.DataAc

2019-01-26 06:32发布

I am building ASP.NET application with C# and I want to connect to oracle database.
I have added reference to Oracle.DataAccess in my application on my 64bit Microsoft Window Server 2008 machine. I also installed ODAC (Oracle Data Access Component) on my machine and Oracle.DataAccess.dll is also present on this path

C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess

but when i'm trying to connect i encounter following error:

Could not load file or assembly 'Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.

7条回答
虎瘦雄心在
2楼-- · 2019-01-26 07:07

As far as I know, the Oracle.DataAccess assembly works only with 32 bits, I also have this kind of problem with 64 bits and it really does not work. My solution was remove the 64bits from GAC and install the 32 bits on GAC. I also remove any .dll file in the bin folder to my application find the assembly on GAC.

There is no problem if your machine and operational system is 64bits, the 32bits version will work fine.

UPDATE

I recommend you take a look at Official Oracle ODP.NET, Managed Driver, that is a better version than Oracle.DataAccess. This Managed Driver does not need the Oracle Client on the machine, and you just need to provide the TNS on the DataSource field of the connection string and it works fine for 32 and 64 bits.

查看更多
地球回转人心会变
3楼-- · 2019-01-26 07:15

I got the same exception on a c# console app. What solved it for me is to change the platform target to x86. (project properties => build )

查看更多
做个烂人
4楼-- · 2019-01-26 07:16

To resolve this error, I set my app pool in IIS to allow 32bit applications. Open up IIS Manager, right click on the app pool, and select Advanced Settings --> set “Enable 32-bit Applications” to True. It's working fine for me.

查看更多
来,给爷笑一个
5楼-- · 2019-01-26 07:22

In VS2010, I changed the platform target to x64 and this error message disappear.

查看更多
不美不萌又怎样
6楼-- · 2019-01-26 07:22

To run your website, you must use IIS since visual studio's development server only runs in 32 bit mode.
In IIS application pool, set your application to run in 64 bit. (The setting is in advanced settings)

查看更多
叼着烟拽天下
7楼-- · 2019-01-26 07:24

essentially same error

missing ODP.NET installation components as per last post from me and the other answer participant.

You check the GAC yet?

If you do not see Oracle.xxx folders,

you are not making any headway.

put the correct version and bit of Oracle.DataAccess.dll into the application /BIN folder and make local reference. It solves many problems.

查看更多
登录 后发表回答