I am trying to connect to an Oracle DB using the following method:
OracleConnection con = new OracleConnection();
con.ConnectionString = "User ID=ID;Password=PASSWORD;Data Source=SOURCE";
con.Open();
write("connected to oracle " + con.ServerVersion);
But every time I run the program I get the error:
[2018-11-01 09:29:19.705] System.BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=PUBLIC_KEY' or one of its dependencies. An attempt was made to load a program with an incorrect format. File name: 'Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=PUBLIC_KEY' at adrentech_previous_day.Program.processFile() at adrentech_previous_day.Program.Main() in DIRECTORY\program:line 25
=== Pre-bind state information === LOG: DisplayName = Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=PUBLIC_KEY (Fully-specified) LOG: Appbase = file:///DIRECTORY LOG: Initial PrivatePath = NULL Calling assembly : adrentech_previous_day, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. === LOG: This bind starts in default load context. LOG: Using application configuration file: DIRECTORY\program.vshost.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Post-policy reference: Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=PUBLIC_KEY LOG: Attempting download of new URL file:///DIRECTORY/Oracle.DataAccess.DLL. ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
Any suggestions?
SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID))); uid=myUsername;pwd=myPassword;
– mason