System.Data.OracleClient 不适用于 64 位 Oracle Client
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24236947/
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
System.Data.OracleClient not working with 64 bit Oracle Client
提问by jetty
I have designed a C# application to connect to Oracle Database and change schema users passwords. My reference assembly is System.Data.OracleClient from the location: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Data.OracleClient.dll"
我设计了一个 C# 应用程序来连接到 Oracle 数据库并更改架构用户密码。我的参考程序集是来自以下位置的 System.Data.OracleClient:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Data.OracleClient.dll”
The platform that I used to design/test the application looks like this: 1. 64 bit Windows 7 platform. 2. 32 bit .Net Frameworkv4.5 3. 32 bit Oracle 10g Client.
我用来设计/测试应用程序的平台如下所示: 1. 64 位 Windows 7 平台。2. 32 位 .Net Frameworkv4.5 3. 32 位 Oracle 10g 客户端。
I need this application to run for 64 bit Oracle Client too. But when I transfer my binaries to a machine which has 64 bit Oracle 11g installed, I get this error: "Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed."
我也需要此应用程序为 64 位 Oracle 客户端运行。但是,当我将二进制文件传输到安装了 64 位 Oracle 11g 的机器时,出现此错误:“尝试加载 Oracle 客户端库引发了 BadImageFormatException。在安装了 32 位 Oracle 客户端组件的 64 位模式下运行时会出现此问题.”
I am not sure how to work around this issue. Please suggest if I need to make any code changes or assembly reference. I read through a lot of similar forums but could not find anything helpful. Please help!
我不知道如何解决这个问题。请建议我是否需要进行任何代码更改或程序集参考。我阅读了很多类似的论坛,但找不到任何有用的东西。请帮忙!
回答by Wernfried Domscheit
First of all, provider System.Data.OracleClient
is deprecated. Microsoft is not supporting it anymore, you should consider to use the Oracle provider Oracle.DataAccess
or Oracle.ManagedDataAccess
.
首先,providerSystem.Data.OracleClient
已被弃用。Microsoft 不再支持它,您应该考虑使用 Oracle 提供程序Oracle.DataAccess
或Oracle.ManagedDataAccess
.
My recommondation is to install both, 32-bit and 64-bit Oracle Client on your developing machine, then you can test and build anything. Here is an instruction how to do this: Install x86 and x64 Oracle Client on one machine
我的建议是在您的开发机器上安装 32 位和 64 位 Oracle 客户端,然后您可以测试和构建任何东西。以下是如何执行此操作的说明:在一台机器上安装 x86 和 x64 Oracle 客户端
An x86 Oracle client can connect to a 64 bit Oracle Database, vice versa is also no problem.
x86 Oracle 客户端可以连接到 64 位 Oracle 数据库,反之亦然。
回答by Amir Tofighi
I had the same issue on a Windows 10 PC. I copied the project from my old computer to the new one, both 64 bits, and I installed the Oracle Client 64 bit on the new machine. I got the same error message, but after trying many solutions to no effect, what actually worked for me was this:
我在 Windows 10 PC 上遇到了同样的问题。我将项目从旧计算机复制到新计算机,均为 64 位,并在新计算机上安装了 64 位 Oracle 客户端。我收到了相同的错误消息,但是在尝试了许多解决方案都没有效果之后,对我来说真正有用的是:
In your Visual Studio (mine is 2017) go to
在您的 Visual Studio(我的是 2017 年)中,转到
Tools > Options > Projects and Solutions > Web Projects
工具 > 选项 > 项目和解决方案 > Web 项目
On that page, check the option that says: Use the 64 bit version of IIS Express for Websites and Projects
在该页面上,选中以下选项:为网站和项目使用 64 位版本的 IIS Express
回答by Nado
Try this:
尝试这个:
- Open Oracle Net Configuration Assistant
- Select radio button option at Local Net Service Name Configuration, then click Next
- Select radio button option at Reconfigure, then click next
- Select net service name you want to reconfigure, either ORACLR_CONNECTION_DATA or ORCL, then click Next
- input your Service Name, if your service name of installed oracle as ORCL, then write ORCL to the field, then click Next
- select the protocol you want to use, for example, select TCP, then click Next
- input hostname where your oracle database engine (service) installed, for example, installed on your desktop or notebook, then fill as localhost, and fill your port number (select option Use the Standar port number of 1521) or if use other port, fill the port number Then click next.
- select Yes perform test, if necessary, change user logon then click next
- if no configure another net service name, select No and then click next
- 打开 Oracle 网络配置助手
- 在本地网络服务名称配置中选择单选按钮选项,然后单击下一步
- 在重新配置中选择单选按钮选项,然后单击下一步
- 选择要重新配置的网络服务名称,ORACLR_CONNECTION_DATA 或 ORCL,然后单击下一步
- 输入你的服务名,如果你安装的oracle的服务名是ORCL,那么在字段中写ORCL,然后点击下一步
- 选择你要使用的协议,例如选择TCP,然后点击下一步
- 输入你的oracle数据库引擎(服务)安装的主机名,例如安装在你的台式机或笔记本上,然后填写localhost,并填写你的端口号(选择选项Use the Standard port number of 1521)或者如果使用其他端口,填写端口号然后点击下一步。
- 选择是执行测试,如有必要,更改用户登录,然后单击下一步
- 如果没有配置另一个网络服务名称,选择否,然后单击下一步
you should download, extract and install the ODTwithODAC183.zip and BuildTools_Full.exe if you want use to connect on .net framework from MS Visual Studio
如果您想从 MS Visual Studio 使用 .net 框架连接,您应该下载、解压并安装 ODTwithODAC183.zip 和 BuildTools_Full.exe