0 Replies Latest reply: Oct 4, 2013 9:28 AM by adi999 RSS

    ODP12 on Mono - works, but I get a "Invalid operation on a closed object"


      Hi, I've got my application running under Mono 3.2.3 on CentOS using the ODP 12 managed provider. There were a few hurdles to overcome, but I got there in the end. Not having to install an Oracle client is a big plus to me, also a single dll for 64 and 32bit saves a headache too.

      However, I did come across a strange problem. When I try to fill a data set using the OracleDataReader I get a "Invalid operation on a closed object" exception. Strange thing is, if I catch the errror and handle it (ignore it), the data set is populated, the connection is still open and my application works perfectly? Has anyone else seen this behavior and is there a way of working around it? I have tried the same code on windows using MS framework 4.5 and it works fine.

      Here's my stack trace.

      System.InvalidOperationException: Invalid operation on a closed object

        at Oracle.ManagedDataAccess.Client.OracleDataReader.get_SchemaTables () [0x00000] in <filename unknown>:0

        at (wrapper remoting-invoke-with-check) Oracle.ManagedDataAccess.Client.OracleDataReader:get_SchemaTables ()

        at Oracle.ManagedDataAccess.Client.OracleDataAdapter.Fill (System.Data.DataSet dataSet, System.String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) [0x00000] in <filename unknown>:0

        at Oracle.ManagedDataAccess.Client.OracleDataAdapter.Fill (System.Data.DataSet dataSet, Int32 startRecord, Int32 maxRecords, System.String srcTable, IDbCommand command, CommandBehavior behavior) [0x00000] in <filename unknown>:0

        at System.Data.Common.DbDataAdapter.Fill (System.Data.DataSet dataSet) [0x00000] in <filename unknown>:0

        at oratest.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

      [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Invalid operation on a closed object



      I managed to replicate the error in a stand alone console app (apologies if the format goes wrong).


      static void Main(string[] args)


          string conX = "User ID=MY_USER_SCHEMA;Password=password;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.?.?)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))";

          using (OracleConnection con = new OracleConnection(conX))



              using (OracleCommand com = con.CreateCommand())


                  com.CommandText = "SELECT * FROM MyTable";

                  com.CommandType = System.Data.CommandType.Text;

                  var da = new OracleDataAdapter(com);

                  DataSet ds = new DataSet();


                  Console.WriteLine(string.Format("Found {0} lines", ds.Tables[0].Rows.Count));