-1

I am installed Oracle Client 12 c and Add Reference System.Data.OracleClient

string oradb = "Data Source=(DESCRIPTION =(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST = ...)(PORT = 1522)))(CONNECT_DATA =(SERVICE_NAME = ****)));User ID=****;Password=****Unicode=True";

Implemented code below

        OracleConnection con = new OracleConnection(oradb);
        OracleCommand cmd = new OracleCommand();
        cmd.CommandText = "SELECT AUXPTYPE,AUXPTYP2 FROM SILAS14_CDS_DIRECTORY WHERE CDSID=RRRRR";
        cmd.Connection = con;
        con.Open();
        OracleDataReader dr = cmd.ExecuteReader();

Error Getting :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.

Rahul Mangal
  • 21
  • 1
  • 4
  • nobody ever reads exception messages :( _"This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed"_ means that you have install 32 bit Oracle client components and tries to run them in 64 bit mode. – vasily.sib May 14 '20 at 05:04

1 Answers1

0

Option 1: You may need to install another instance with Oracle Client 12 c - 64 bit, then you can run your codes correctly.

Option 2: Or, you can try to change the project build type in Visual Studio from Any CPU/x64 to x86 to make your DB call in 32 bit mode.

To change build type: Right click the project in Visual Studio -> Select Build tab -> Platform target -> x86.

Shawn Xiao
  • 560
  • 5
  • 18
  • I have done all these thing but this is not working and i have installed winx64_12201_client Oracle client – Rahul Mangal May 15 '20 at 05:26
  • After you installed the 64-bit Oracle Client, please remove the reference `System.Data.OracleClient` and add the reference to 64-bit version. If no lucky, please refer: [LINK](https://stackoverflow.com/a/24237891/13378146) – Shawn Xiao May 15 '20 at 05:44