[Mono-list] Help with ADO.NET Oracle client

David Pickens dsp@rci.rutgers.edu
Sun, 06 Apr 2003 23:21:41 -0400


Thanks for the response.  After some more confusion, I decided to dig 
around in sqlsharp to see what it was doing (that I wasn't) to get the 
oracle client to work.  I discovered that it connects using something 
like the following:

                        conn.ConnectionString = connectionString;
                        try {
                                if(conn.State == ConnectionState.Open)
                                        Console.WriteLine("Open was 
Whereas the sample code from the website (go-mono.org) does:

       IDbConnection dbcon;
       dbcon = new OracleConnection (connectionString);
       dbcon.Open ();

As far as I can tell (which is to say, on my system) the above does not 
work, but changing it so that it sets dbcon.ConnectionString = 
connectionString *does* work.  I don't know if the website or the 
OracleConnection constructor is to blame (or if it's something on my 

One problem down, now on to mod_mono:

You suggested missing environment variables may be to blame, so I 
whipped up an ASP.NET page to print the environment variables mod_mono 
sees from the System.Environment class, and snipping only the relevant 
lines, it shows the following:


ORACLE_HOME= /home/oracle/product/8.1.7

ORACLE_BASE= /home/oracle

LD_LIBRARY_PATH= /home/oracle/product/8.1.7/lib

ORACLE_SID= oracle

The environment seems OK.  I'm hoping that Tim or someone with mod_mono 
experience can tell me why it would have problems loading the oracle 
libraries in mod_mono, but not in a standalone app, given the above.  A 
parital stack trace follows...

System.MissingMethodException: A missing method exception has occurred.
in <0x00046> 06 System.Data.OracleClient.Oci.OciEnvironmentHandle:OCIEnvCreate (intptr&,System.Data.OracleClient.Oci.OciEnvironmentMode,intptr,intptr,intptr,intptr,int,intptr)
in <0x00063> 00 System.Data.OracleClient.Oci.OciEnvironmentHandle:.ctor (System.Data.OracleClient.Oci.OciEnvironmentMode)
in <0x0002c> 00 System.Data.OracleClient.Oci.OciGlue:CreateConnection (System.Data.OracleClient.OracleConnectionInfo)
in <0x0008e> 00 System.Data.OracleClient.OracleConnection:Open ()



Tim Coleman wrote:

>On Tue, 2003-04-01 at 23:59, David Pickens wrote: 
>>Let me say first that I'm new to mono, and relatively new to C# (moving 
>>from C++), so the following problems could be a result of my 
>>inexperience, but I can't seem to get the sample code from go-mono.org 
>>to work, nor does my attempt in my own code to open the database 
>>connection work.  (However, using sqlsharp, /Provider Oracle, and a 
>>valid connection string *does* work on the system, and I do have oracle 
>>installed and working correctly on the system in question.)
>>I've corrected the missing casting to strings in the demo code, but when 
>>it does compile successfully, and the connection string is valid I get:
>>Unhandled Exception: System.NullReferenceException: A null value was 
>>found where an object instance was required
>>in <0x00018> 00 System.Data.OracleClient.Oci.OciServerHandle:Attach ()
>>in <0x00470> 00 System.Data.OracleClient.Oci.OciGlue:CreateConnection 
>>in <0x0008e> 00 System.Data.OracleClient.OracleConnection:Open ()
>>in <0x00095> 00 .Test:Main (string[])
>>My own connection code, in an ASP.NET page used by mod_mono/apache2 returns:
>>System.MissingMethodException: A missing method exception has occurred.
>>in <0x00046> 06 
>>in <0x00063> 00 System.Data.OracleClient.Oci.OciEnvironmentHandle:.ctor 
>>in <0x0002c> 00 System.Data.OracleClient.Oci.OciGlue:CreateConnection 
>>in <0x0008e> 00 System.Data.OracleClient.OracleConnection:Open ()
>>in <0x00080> 00 GSNB.GSNBDataAccess:.ctor ()
>>The version of mono is 0.23 (debs).
>>Any help will be appreciated!
>Since the Oracle provider *does* work for you with SQL#, and it seems in
>the first example that the error is occuring in
>OciServerHandle.Attach(), I think that there may be a problem with your
>connection string.  If you could send me the details, perhaps I could
>check it out.
>In the second example, it almost seems that it can't find the Oracle
>client libraries that you have installed.  Not knowing much about
>mod_mono, I can't really say why that may be, but you might want to
>check out the LD_LIBRARY_PATH or somesuch for the apache user.