C# 无法加载文件或程序集 'Oracle.DataAccess 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15293975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load file or assembly 'Oracle.DataAccess error
提问by RAKESH HOLKAR
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# 构建 ASP.NET 应用程序,我想连接到 oracle 数据库。
我Oracle.DataAccess
在我的 64 位 Microsoft Window Server 2008 机器上的应用程序中添加了引用。我还在我的机器上安装了 ODAC(Oracle 数据访问组件)并且Oracle.DataAccess.dll
也在这条路径上
C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess
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.
无法加载文件或程序集“Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342”或其依赖项之一。该系统找不到指定的文件。
采纳答案by Felipe Oriani
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.
据我所知,该Oracle.DataAccess
程序集仅适用于 32 位,我也有这种 64 位的问题,它确实不起作用。我的解决方案是从 GAC 中删除 64 位并在 GAC 上安装 32 位。我还将 bin 文件夹中的任何 .dll 文件删除到我的应用程序中,在 GAC 上找到程序集。
There is no problem if your machine and operational system is 64bits, the 32bits version will work fine.
如果您的机器和操作系统是 64 位,则没有问题,32 位版本可以正常工作。
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.
我建议你看一看Official Oracle ODP.NET, Managed Driver
,那是一个比Oracle.DataAccess
. 这Managed Driver
不需要Oracle Client
在机器上,你只需要提供的数据源领域的TNSconnection string
和它的作品罚款32
和64
位。
回答by nvoigt
You need to install both x64 and x86 versions of Oracle, because something (I think it was Visual Studio) uses the x86 version when debugging.
您需要同时安装 x64 和 x86 版本的 Oracle,因为某些(我认为是 Visual Studio)在调试时使用 x86 版本。
回答by nvoigt
essentially same error
基本相同的错误
missing ODP.NET installation components as per last post from me and the other answer participant.
根据我和其他回答参与者的最后一篇文章,缺少 ODP.NET 安装组件。
You check the GAC yet?
你检查 GAC 了吗?
If you do not see Oracle.xxx folders,
如果您没有看到 Oracle.xxx 文件夹,
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.
将 Oracle.DataAccess.dll 的正确版本和位放入应用程序 /BIN 文件夹中并进行本地引用。它解决了很多问题。
回答by Hüseyin Ya?l?
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)
要运行您的网站,您必须使用 IIS,因为 Visual Studio 的开发服务器只能在 32 位模式下运行。
在 IIS 应用程序池中,将您的应用程序设置为以 64 位运行。(设置在高级设置里)
回答by Vu Doan
In VS2010, I changed the platform target to x64 and this error message disappear.
在 VS2010 中,我将平台目标更改为 x64,此错误消息消失了。
回答by Venkat
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.
为了解决这个错误,我在 IIS 中设置了我的应用程序池以允许 32 位应用程序。打开 IIS 管理器,右键单击应用程序池,然后选择高级设置 --> 将“启用 32 位应用程序”设置为 True。它对我来说很好用。
回答by nir weiner
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 )
我在 ac# 控制台应用程序上遇到了同样的异常。为我解决的是将平台目标更改为 x86。(项目属性 => 构建)