Reputation: 9
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);
Upvotes: 0
Views: 2245
Reputation: 500
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.
Upvotes: 1
Reputation: 957
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.
Upvotes: 0
Reputation: 9
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.
Upvotes: 0