7 Replies Latest reply: Oct 8, 2012 6:32 PM by Alex.Keh .Product.Manager-Oracle RSS

    Error using Managed ODP.NET Beta on Mono on Windows

    441662
      The beta for the fully managed edition of the ODP.NET provider fails to work on Mono.

      Oracle Data Provider for .NET, Managed Driver Beta 11.2.0.3.50
      http://www.oracle.com/technetwork/database/windows/downloads/odpmbeta-1696432.html

      I am running Mono on Windows 7 32-bit.
      Mono is version 2.11.4 for Windows.

      Managed ODP.NET is designed to work on .NET 4.0. I have Visual Studio 2010 SP1 and Oracle 11g Release 2 for Windows 32-bit.

      The example works on .net 4.0, but the program throws an exception on Mono.

      The exception is a TypeInitializationException for OracleInternal.ServiceObjects.OracleGlobalizationImpl.
      TimeZoneNotFoundException.

      Or do I have something not setup correctly?

      Here is the exception:

      D:\projects\oracle_managed\oracle_managed\bin\Debug>mono oracle_managed.exe
      Error: System.TypeInitializationException: An exception was thrown by the type i
      nitializer for OracleInternal.ServiceObjects.OracleGlobalizationImpl ---> System
      .TimeZoneNotFoundException: Exception of type 'System.TimeZoneNotFoundException'
      was thrown.
      at System.TimeZoneInfo.get_Local () [0x00000] in <filename unknown>:0
      at OracleInternal.ServiceObjects.OracleGlobalizationImpl.InitFromClient (Oracl
      eInternal.ServiceObjects.OracleGlobalizationImpl implObj) [0x00000] in <filename
      unknown>:0
      at OracleInternal.ServiceObjects.OracleGlobalizationImpl..cctor () [0x00000] i
      n <filename unknown>:0
      --- End of inner exception stack trace ---
      at OracleInternal.ServiceObjects.OracleConnectionImpl.AlterSessionOnConnect (O
      racle.ManagedDataAccess.Client.OracleConnection con) [0x00000] in <filename unkn
      own>:0
      at Oracle.ManagedDataAccess.Client.OracleConnection.Open () [0x00000] in <file
      name unknown>:0
      Press RETURN to exit.

      Also, why is the Mono Windows Installer 90MB. That is huge to download.
      Also, why are you including all the static libraries (they have a one letter file extension of .a)?
      Most users/developers of Mono do not use these static libraries.

      If developers need these archives, is it possible to create a separate installer that includes those static archives? I think the people who need it might be those who build mono or gtk# on windows.

      Here is the sample program I ran to use Oracle.ManagedDataAccess.dll

      using System;
      using Oracle.ManagedDataAccess.Client;
      using Oracle.ManagedDataAccess.Types;

      namespace Connect
      {
      class Program
      {
      static void Main(string[] args)
      {
      try
      {
      // Please replace the connection string attribute settings
      string constr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=testdb11)));User ID=scott;Password=tiger";

      OracleConnection con = new OracleConnection(constr);

      con.Open();
      Console.WriteLine("Connected to Oracle Database {0}", con.ServerVersion);

      /*
      OracleCommand cmd = con.CreateCommand();
      cmd.CommandText = "SELECT view_name FROM all_views WHERE rownum < 5";
      OracleDataReader reader = cmd.ExecuteReader();
      Console.WriteLine("Views");
      int viewCount = 0;
      while (reader.Read())
      {
      string viewName = reader.GetString(reader.GetOrdinal("view_name"));
      Console.WriteLine("View: {0}", viewName);
      viewCount++;
      }
      Console.WriteLine("View count: {0}", viewCount);
      */
      con.Dispose();

      Console.WriteLine("Press RETURN to exit.");
      Console.ReadLine();
      }
      catch (Exception ex)
      {
      Console.WriteLine("Error: {0}", ex);

      Console.WriteLine("Press RETURN to exit.");
      Console.ReadLine();
      }
      }
      }
      }
        • 1. Re: Error using Managed ODP.NET Beta on Mono on Windows
          Tridus
          SQL Dan wrote:

          The exception is a TypeInitializationException for OracleInternal.ServiceObjects.OracleGlobalizationImpl.
          TimeZoneNotFoundException.

          Or do I have something not setup correctly?
          That error looked like it couldn't find your local timezone.

          (Note that Mono isn't actually supported by Oracle, so it may or may not work.)
          Also, why is the Mono Windows Installer 90MB. That is huge to download.
          Also, why are you including all the static libraries (they have a one letter file extension of .a)?
          Most users/developers of Mono do not use these static libraries.
          Huh? This sounds like a question for the Mono project.
          • 2. Re: Error using Managed ODP.NET Beta on Mono on Windows
            Invincible
            I have tried to use Oracle Managed under Linux/Mono but I'm getting an error

            Invalid type Oracle.ManagedDataAccess.Client.OracleCommand for instance field OracleInternal.ServiceObjects.OracleGlobalizationImpl:m_cmd

            Unhandled Exception:
            System.TypeLoadException: A type load exception has occurred.
            at Oracle.ManagedDataAccess.Client.OracleConnection.Open () [0x00000] in <filename unknown>:0
            Invalid type Oracle.ManagedDataAccess.Client.OracleCommand for instance field Oracle.ManagedDataAccess.Client.OracleTransaction:m_command
            [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: A type load exception has occurred.
            at Oracle.ManagedDataAccess.Client.OracleConnection.Open () [0x00000] in <filename unknown>:0
            • 3. Re: Error using Managed ODP.NET Beta on Mono on Windows
              965706
              I got the exact same result.

              Same setup : Managed ODP.NET, Visual Studio 2010 SP1 project, Oracle 11g R2 DB

              Compiled the little sample code found in the readme.htm file.

              With the Microsoft .Net 4.0 framework : Connected to Oracle Database 11.2.0.3.0

              With the Mono 2.11 framework (on Windows) : Exception of type 'System.TimeZoneNotFoundException' was thrown.

              Sad that such simple code does not even work on Mono.
              I would have hoped that at least some of Managed ODP.NET library would work on Mono.


              J-F
              • 4. Re: Error using Managed ODP.NET Beta on Mono on Windows
                Invincible
                My testing on mono and linux didn't go well either.
                It's looks like that fully managed means with P/Invoke using because of this:
                     [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
                     [return: MarshalAs(UnmanagedType.Bool)]
                     private static extern bool GlobalMemoryStatusEx([In] [Out] OracleTuner.SystemInfo.MEMORYSTATUSEX lpBuffer);
                     [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
                     private static extern void GlobalMemoryStatus([In] [Out] OracleTuner.SystemInfo.MEMORYSTATUS lpBuffer);

                ~/> mono --trace=E:all ./OracleTest.exe
                [0x7f679fad6740:] EXCEPTION handling: System.EntryPointNotFoundException: GlobalMemoryStatusEx

                "<unnamed thread>" tid=0x0x7f679fad6740 this=0x0x7f679f92bea0 thread handle 0x403 state : not waiting owns ()
                at (wrapper managed-to-native) OracleInternal.SelfTuning.OracleTuner/SystemInfo.GlobalMemoryStatusEx (OracleInternal.SelfTuning.OracleTuner/SystemInfo/MEMORYSTATUSEX) <0xffffffff>
                at OracleInternal.SelfTuning.OracleTuner/SystemInfo.getTotalVirtualAndPhysicalMemory (ulong&,ulong&) <0x0005b>
                at OracleInternal.SelfTuning.OracleTuner..ctor () <0x000af>
                at OracleInternal.SelfTuning.OracleTuner..cctor () <0x00033>
                at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>
                at <unknown> <0xffffffff>
                at OracleInternal.ConnectionPool.OraclePoolManager.Initialize (Oracle.ManagedDataAccess.Client.ConnectionString) <0x00093>
                at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.GetPM (Oracle.ManagedDataAccess.Client.ConnectionString,PM,Oracle.ManagedDataAccess.Client.ConnectionString,byte[],byte[],bool&,bool&) <0x00152>
                at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get (Oracle.ManagedDataAccess.Client.ConnectionString,PM,Oracle.ManagedDataAccess.Client.ConnectionString,byte[],byte[]) <0x0012b>
                at Oracle.ManagedDataAccess.Client.OracleConnection.Open () <0x00453>
                at OracleTest.MainClass.Main (string[]) <0x0005f>
                at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <0xffffffff>
                Invalid type Oracle.ManagedDataAccess.Client.OracleCommand for instance field OracleInternal.ServiceObjects.OracleGlobalizationImpl:m_cmd
                [0x7f679fad6740:] EXCEPTION handling: System.TypeLoadException: A type load exception has occurred.
                • 5. Re: Error using Managed ODP.NET Beta on Mono on Windows
                  yallie
                  Hi,

                  There is a feature request (Support ODP.NET on Mono) awaiting community votes:
                  https://apex.oracle.com/pls/apex/f?p=18357:39:1783488259248::NO::P39_ID:26141

                  Please vote for it if you feel it's important.
                  • 6. Re: Error using Managed ODP.NET Beta on Mono on Windows
                    Invincible
                    I have voted for this feature a long time ago.
                    The support for mono is the second most requested after Fully managed provider but both go hand in hand, If the provider is fully managed It should work on mono when there are p/invokes in code for me this is not fully managed.
                    • 7. Re: Error using Managed ODP.NET Beta on Mono on Windows
                      Alex.Keh .Product.Manager-Oracle
                      The first managed ODP.NET release will not officially support Mono. Oracle will consider supporting Mono in a future release.