问题
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:
- 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
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