0

I have a C# project that I want to switch to the x64 platform. It was using the Oracle.DataAccess.dll 32 bit to make DB connections and it worked fine.

I'm using VS 2019.

I installed the 64 bit ODAC from Oracle here: https://www.oracle.com/database/technologies/dotnet-odacdeploy-downloads.html

I changed the platform and platform target in the build properties to be x64.

I moved the 64 bit Oracle.DataAccess.dll to the bin folder of the project.

Now, every time I try to open a connection using this code:

 string connString = ConfigurationManager.AppSettings["DBCS"].Replace("<dbname>", dbname);
 OracleConnection con = new OracleConnection();
 con.ConnectionString = connString;
 con.Open();

It throws the error when it hits con.Open();:

{"Object reference not set to an instance of an object."}
   at Oracle.DataAccess.Client.OracleException.get_Number()
   at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32 isRecoverable, OracleLogicalTransaction m_OracleLogicalTransaction)
   at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src, OracleLogicalTransaction m_oracleLogicalTransaction)
   at Oracle.DataAccess.Client.OracleConnectionOCP.Open(OracleConnection con)
   at Oracle.DataAccess.Client.OracleConnection.Open()
   at TASWebServices.App_Code.DatabaseCalls.ReportDatabaseCalls..ctor(String dbname) in C:\ReportDatabaseCalls.cs:line 30
   atGetReportName(Nullable`1 corrID, Nullable`1 batchID, String username, String dbname) in C:\ReportController.cs:line 219

Any idea what I need to do to get the 64 bit Oracle.DataAccess.dll to work?

J.Cart
  • 519
  • 1
  • 8
  • 19
  • Possible duplicate [Deploying ASP.NET website with ODP.NET](https://stackoverflow.com/questions/25681641/deploying-asp-net-website-with-odp-net) – coder_b Nov 24 '20 at 14:55
  • 1
    Try using the [ODP.NET NuGet package](https://www.nuget.org/packages/Oracle.ManagedDataAccess/) instead of manually copying around DLLs. – Jeroen Mostert Nov 24 '20 at 15:00
  • Thanks @JeroenMostert, Nuget package was the way to go, it is working – J.Cart Nov 24 '20 at 15:07

0 Answers0