[Mono-aspnet-list] Mono - Oracle Connectivity Sample Program

ChristinaP christina.peter at tcs.com
Thu Jul 9 07:31:31 EDT 2009


Hi,

I am trying to connect to an Oracle DB in Mono on openSuse11.1 and getting
the following error:
Description: HTTP 500. Error processing request.

Stack Trace:

System.DllNotFoundException: libclntsh.so
  at (wrapper managed-to-native)
System.Data.OracleClient.Oci.OciCalls/OciNativeCalls:OCIEnvCreate
(intptr&,System.Data.OracleClient.Oci.OciEnvironmentMode,intptr,intptr,intptr,intptr,int,intptr)
  at System.Data.OracleClient.Oci.OciCalls.OCIEnvCreate (System.IntPtr&
envhpp, OciEnvironmentMode mode, IntPtr ctxp, IntPtr malocfp, IntPtr
ralocfp, IntPtr mfreep, Int32 xtramem_sz, IntPtr usrmempp) [0x00000] 
  at System.Data.OracleClient.Oci.OciEnvironmentHandle..ctor
(OciEnvironmentMode mode) [0x00000] 
  at System.Data.OracleClient.Oci.OciGlue.CreateConnection
(OracleConnectionInfo conInfo) [0x00000] 
  at System.Data.OracleClient.OracleConnectionPoolManager.CreateConnection
(OracleConnectionInfo info) [0x00000] 
  at System.Data.OracleClient.OracleConnectionPool.CreateConnection ()
[0x00000] 
  at System.Data.OracleClient.OracleConnectionPool.GetConnection ()
[0x00000] 
  at System.Data.OracleClient.OracleConnection.Open () [0x00000] 
  at (wrapper remoting-invoke-with-check)
System.Data.OracleClient.OracleConnection:Open ()
  at ASP.asdf_oratest_aspx.Page_Load (System.Object sender, System.EventArgs
e) [0x00000] 
  at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00000] 
  at System.Web.UI.Control.LoadRecursive () [0x00000] 
  at System.Web.UI.Page.ProcessLoad () [0x00000] 
  at System.Web.UI.Page.ProcessPostData () [0x00000] 
  at System.Web.UI.Page.InternalProcessRequest () [0x00000] 
  at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context)
[0x00000] 

Version information: Mono Version: 2.0.50727.1433; ASP.NET Version:
2.0.50727.1433--------------------------
--------------
I am doing the following steps:
1) Verified that System.Data.OracleClient.dll is present in the directory
/usr/lib/mono/2.0/
2) Downloaded the OracleInstantClient for 32 bit Linux and kept all the
unzipped files in a local directory on OpenSuse called
"/usr/local/instant_client_10_2/"
3) The files present in this folder are as follows: (a)libclntsh.so.10.1
(b)libnnz10.so (c)libocci.so.10.1 (d) libociei.so (e)libocijdbc10.so
(f)classes12.jar (g)ojdbc14.jar
3) Informed Apache server of the location of the Instant Client Software
    Did this by: (a) creating an oracleinstantclient.conf file containing
the path "/usr/local/instant_client_10_2/" and placing this file in
/etc/ld.so.conf.d
                      (b) restarted the machine / typed ldconfig to reflect
these configuration changes
                       (c) restarted apache2 using /etc/init.d/apache2
restart
4) Created the test OracleTesting.aspx in /srv/www/htdocs/OracleTest
directory
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Assembly name="System.Data.OracleClient" %>
<%@ Import Namespace="System.Data.OracleClient" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<script runat="server">
     
     protected void Page_Load(object sender, EventArgs e)
     {
         String connstring = "User ID=system;" +
         "Password=password;" +
         "Data Source= \'(" +
         "DESCRIPTION=(" +
         "ADDRESS=(PROTOCOL=TCP)(HOST=172.121.0.9)(PORT=1521)" +
         ")" +
         "(CONNECT_DATA=(SERVER=DEDICATED)" +
         "(SERVICE_NAME=XE)))\'";
 
         using (OracleConnection conn = new OracleConnection(connstring))
         {
             using (OracleCommand cmd = new OracleCommand())
             {   
                 cmd.Connection = conn;
                 conn.Open();
                 cmd.CommandText = "SELECT SYSDATE FROM DUAL";
                 DateTime retVal = (DateTime)cmd.ExecuteScalar();
                 lblOracle.Text = "Server time is:" +
                     retVal.ToLongDateString() + " " +
                     retVal.ToLongTimeString();
              
             }
         }
     }
 
</script>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
     <title></title>
</head>
<body>
     <form id="form1" runat="server">
     <asp:Label ID="lblOracle" runat="server"></asp:Label>
     </form>
</body>

5) Then when I test this page onto a web browser, it gives me the above
error.
6) Based on some googling, I understood that Mono's Oracle dll is hard coded
to look for the file libclntsh.so which was the correct file for the
original Oracle client, but the name of the file changes with each Oracle
Instant Cient update so all you have to do is reroute the call. I do that
with a quick symbolic link (Linux's version of a Windows Shortcut) in the
instant Client folder. In my case the /usr/local/instant_client_10_2/ folder
had the file named libclntsh.so.10.1 to match the Instant Client version
10.1 so made a new file link this:
ln –s libclntsh.so.10.1 libclntsh.so
7) Still I am getting the same error… for libclntsh.so


Anybody has any pointers.... Thanks, christina

-- 
View this message in context: http://www.nabble.com/Mono---Oracle-Connectivity-Sample-Program-tp24408522p24408522.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.



More information about the Mono-aspnet-list mailing list