Question

I have created a C# console project using Visual Studio 2008 and OracleClient (OCI) libraries to connect to a Oracle 11g database. This code works in Windows. I copied the whole project into Linux and Open the solution using MonoDevelop 4.2.3. But while running the project, the Database Open call throws an exception

    string connectionString = "Data Source=Test; User ID=UID; Password=PWD"
    OracleConnection conn = new OracleConnection()
    conn.ConnectionString = connectionString;
    conn.Open();

Exception:

System.DllNotFoundException: libclntsh.so at (wrapper managed-to-native) System.Data.OracleClient.Oci.OciCalls/OciNativeCalls:OCIEnvCreate

The libclntsh.so file is under the location /home/dbuser/instantclient_12_1

I have set the environment variable by adding the below in the /home/dbuser/.bashrc file and rebooted the system.

export LD_LIBRARY_PATH=/home/dbuser/instantclient_12_1:$LD_LIBRARY_PATH

But still I am getting the same error. I couldn't find any option to include the Libraries in the MonoDevelop.

Thanks

Was it helpful?

Solution 2

I have resolved the issue by doing the following

echo $ORACLE_HOME/lib > /etc/ld.so.conf.d/dbconf.conf

set the$ORACLE_HOME, $ORACLE_INCLUDE_PATH and $ORACLE_LIB_PATH to /etc/profile.d

Because of some reason MonoDevelop IDE is not picking the library libclntsh.so if I use the OCI client libraries

OTHER TIPS

Looks like LD_LIBRARY_PATH environment variable is not set up correctly or does not get applied.

Try creating additional linker configuration file instead with the following command:

echo /home/dbuser/instantclient_12_1 > /etc/ld.so.conf.d/instantclient.conf

Then as root update linker cache with command:

ldconfig

Restart MonoDevelop and try again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top