0

I am trying to connect to a remote oracle database with my c# application, but when it comes to the oracleconnection.open() it exits with

AccessViolationException was unhandled - Attempted to read or write protected memory. This is often an indication that other memory is corrupt

my connection string is key="oracleconnectionstring" value="Data Source=XYZ; password=mypassword; User ID=myuserid" in the app.config file.

the tnsnames.ora is

XYZ = 
  (DESCRIPTION = 
    (ADDRESS_LIST = 
      (ADDRESS = (PROTOCOL = TCP)(HOST = HostName)(PORT = 1521))
    ) 
    (CONNECT_DATA = 
      (SERVICE_NAME = XYZ)
    )
  )

If I try to connect via Sql Developer it connects without any problems, if I try SqlPlus it just crashes (Sql*Plus has stopped working) and if I try with VS it gives me that strange error.

what can it be?

EDIT: if I try to tnsping xyz it returns OK (100ms);

3
  • Please post the code you are using to connect - what oracle connection library are you using - what have you tried? Commented Apr 15, 2016 at 13:30
  • I am using Oracle.DataAccess Version 4.112.2.0 Runtime v4.0.30319; the code gets the connection string from the config file and then it does: oracleconnection = new OracleConnection(oracleconnectionstring); oracleconncetion.Open(); Commented Apr 15, 2016 at 13:33
  • It seems to be getting the correct elements from the config when I analyze the connectionstring in debug; Commented Apr 15, 2016 at 13:38

3 Answers 3

1

There seems to be many causes of this error. One other thing to check is the compatibility of the Oracle.DataAccess.dll and the Oracle client on the machine you run the app.

The notation for checking the version compatibility is described here - as an example Oracle client version 11.2.0.2 corresponds to version 4.112.2.0 of Oracle.DataAccess.dll. You can check the version of the client e.g. by running sqlplus -v and the version of the DLL by right-clicking it and going to the Details tab.


Side note:

In my particular case it was even stranger - even though on paper my client was compatible with the Oracle.DataAccess.dll it still didn't work.
I tracked the issue down to the ORACLE_HOME/bin/OraOps12.dll and it turned out that if I use the version of the file
[2.121.2.0 ODAC RELEASE 4; Date Modified 2017/09/25]
it does not work but if I use the version
[2.121.2.0; Date Modified 2014/09/08]
it does.
So as a result I used this older version of the client.

Sign up to request clarification or add additional context in comments.

Comments

0

In the end I managed that with a clean installation of Oracle Client and ODT for VisualStudio and it worked, I will never now which was exactly the problem.

Comments

0

If you're using the Connection in a threaded Environment it might help to assign separate Connections to the different threads. The OracleConnection object seems not to be threadsave.

I had the exact same issue and I could track it back to this cause.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.