System.Data.OracleClient not working with 64 bit Oracle Client

旧巷老猫 提交于 2020-12-11 04:38:20

问题


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"

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.

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

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!


回答1:


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.

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

An x86 Oracle client can connect to a 64 bit Oracle Database, vice versa is also no problem.




回答2:


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:

In your Visual Studio (mine is 2017) go to

Tools > Options > Projects and Solutions > Web Projects

On that page, check the option that says: Use the 64 bit version of IIS Express for Websites and Projects




回答3:


Try this:

  1. Open Oracle Net Configuration Assistant
  2. Select radio button option at Local Net Service Name Configuration, then click Next
  3. Select radio button option at Reconfigure, then click next
  4. Select net service name you want to reconfigure, either ORACLR_CONNECTION_DATA or ORCL, then click Next
  5. input your Service Name, if your service name of installed oracle as ORCL, then write ORCL to the field, then click Next
  6. select the protocol you want to use, for example, select TCP, then click Next
  7. 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.
  8. select Yes perform test, if necessary, change user logon then click next
  9. if no configure another net service name, select No and then click next

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



来源:https://stackoverflow.com/questions/24236947/system-data-oracleclient-not-working-with-64-bit-oracle-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!