16

Overview

I want to replace Oracle.DataAccess with Orcale.ManagedDataAccess, but opening a connection with the latter throws an ORA-12537 network session end of file exception.

Exception message / stack trace

{OracleInternal.Network.NetworkException (0x000030F9): ORA-12537: Netzwerksession: Dateiende at OracleInternal.Network.ReaderStream.Read(OraBuf OB) at OracleInternal.TTC.OraBufReader.GetDataFromNetwork() at OracleInternal.TTC.OraBufReader.Read(Boolean bIgnoreData) at OracleInternal.TTC.MarshallingEngine.UnmarshalUB1(Boolean bIgnoreData) at OracleInternal.TTC.TTCProtocolNegotiation.ReadResponse()}

I am trying to connect to a Oracle 11g database and do not have a client installed on my local machine.

Working test application (unmanaged)

Using Oracle.DataAccess works fine.

using System;
using Oracle.DataAccess.Client;

namespace App.Odp.Unmanaged
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //dummy connection string. using SID 
            string connectionString = "User Id=***;password=***;Data Source=1.2.3.4:1521/sid01;";

            try
            {
                using (var conn = new OracleConnection(connectionString))
                {
                    conn.Open();
                    using (OracleCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "select * from all_users";

                        using (OracleDataReader reader =     cmd.ExecuteReader())
                        {                            
                            Console.WriteLine("VisibleFieldCount: {0}", reader.VisibleFieldCount);
                            Console.WriteLine("HiddenFieldCount: {0}", reader.HiddenFieldCount);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error:{0}", ex.Message);
            }

            Console.ReadLine();
        }
    }
}

References and dependencies

  • Oracle.DataAccess (2.111.7.0)
  • oci.dll (11.1.0.1)
  • orannzsbb11.dll (11.1.0.6)
  • oraociei11.dll (Oracle Call Interface Instant Client)
  • OraOps11w.dll (2.111.7.0)

Project settings

Plattform target x86
Target Framework 4.5

Failing test application (managed)

Using the nuget package Official Oracle ODP.NET, Managed Driver 12.1.21

Code is identical to above. Only change:

using System;
using Oracle.ManagedDataAccess.Client;
//... rest the same as above

References and dependencies

Only:

  • Oracle.ManagedDataAccess (4.121.2.0)

Project settings

Plattform target Any CPU
Target Framework 4.5

App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client" />
      <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
  </system.data>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <publisherPolicy apply="no" />
        <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
        <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.121.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <oracle.manageddataaccess.client>
    <version number="*">
      <dataSources>
        <!--<dataSource alias="MyDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=1.2.3.4)(PORT=1521))(CONNECT_DATA=(SID=sid01)))" />-->
      </dataSources>
      <settings>
        <!--<setting name="SQLNET.AUTHENTICATION_SERVICES" value="NTS"/>-->
      </settings>
    </version>
  </oracle.manageddataaccess.client>
</configuration>

I have tried different settings (NTS, none, all) and changed the connection string to User Id=XXX;password=XXX;Data Source=MyDataSource;, but the error stays the same.

Questions

  • What could be causing the ORA-12537 network session end of file exception?
  • Is a reference / dependency missing?
  • Does something have to be configured on the DB server?

UPDATE

On the server we are getting an ORA-12679: Native services disabled by other process but required error in the alert.log.

It seems to have something to do with the encryption. Commenting out the following lines in the servers sqlnet.ora solves the issue.

#SQLNET.AUTHENTICATION_SERVICES=(NTS)
#SQLNET.ENCRYPTION_TYPES_SERVER = (rc4_128, rc4_256)
#SQLNET.ENCRYPTION_SERVER=REQUIRED
#ENCRYPTION_WALLET_LOCATION=
#          (SOURCE=(METHOD=FILE)(METHOD_DATA=
#                  (DIRECTORY=...\%ORACLE_SID%\wallet)))

New question

How do we configure ManagedDataAccess so it works with the encryption?

Update 2

Seems to work now with ODP Managed Driver 12c:
https://www.nuget.org/packages/Oracle.ManagedDataAccess/

Greg
  • 1,076
  • 1
  • 9
  • 17
  • The connection is being lost - this could be because of a firewall, a Oracle networking setting or a error in the database. A few things: Prior to trying out managed, did you use the same exact connect string you are using now, or did you use TNS alias or a different database/sid? Have your DBA check the Alert Log for an error occuring when you attempt to connect. – Christian Shay Apr 24 '15 at 16:47
  • Also, check for internal exceptions while debugging your app. There might be additional ORA errors that could point to the cause of the lost connection. – Christian Shay Apr 24 '15 at 16:51
  • Yes, I used the identical connection string. I'll ask the DBA to check for errors. – Greg Apr 27 '15 at 07:17
  • What about additional ORA errors in the inner exception? – Christian Shay Apr 27 '15 at 19:04
  • It seems a **ORA-12679: Native services disabled by other process but required** is being thrown on the DB. Not sure what is meant with native services. Could not find any useful solutions to this error message so far. – Greg Apr 28 '15 at 09:34
  • When you say "thrown on the DB", do you mean it is in the alert log or that it is in the inner exception that you are catching in your code? – Christian Shay Apr 30 '15 at 06:16
  • I meant the alert.log. I've updated the question yesterday. If we remove the settings mentioned above it works. We are currently trying to narrow it down, but it seems to have something to do with the encryption settings. – Greg Apr 30 '15 at 08:49
  • Thanks Greg. I figured out what is going on. See my answer below. – Christian Shay Apr 30 '15 at 19:32
  • I just tried to upgrade from https://www.nuget.org/packages/Oracle.ManagedDataAccess/12.1.24160719 to the latest version https://www.nuget.org/packages/Oracle.ManagedDataAccess/12.2.1100 and it didn't seem to help – Matt Kocaj Jun 08 '17 at 06:38

6 Answers6

3

Edit: ASO is now supported. Upgrade to ODAC 12c Release 4 or later. If this does not fix your problem, check the alert.log on the database server and investigate (google) any errors that occur there when you attempt to connect.


Original Answer:

As of this writing (4/30/15) there is no support for Oracle Advanced Security Option (ASO) encryption with ODP.NET Managed Driver which is what is causing your errors.

This is very likely to be supported at some point in the future so if you are reading this at a later date, check the latest ODP.NET docs to see if an upgrade of ODP.NET is needed.

http://docs.oracle.com/cd/E56485_01/win.121/e55744/InstallConfig.htm#CHDJIDIG

Christian Shay
  • 2,570
  • 14
  • 24
  • Thanks for the help. That is a shame though. Was really hoping to get rid of the large unmanaged libraries. I guess we will just have to wait a bit longer. – Greg Apr 30 '15 at 22:06
  • 1
    Sorry about that. :( Managed driver is fairly new as of this writing, and all the networking and security layers had to be rewritten in managed code. Some things had to be put off till "later" and this is one of them. I suggest you search the feature request page for "ASO" and vote for it: http://apex.oracle.com/pls/apex/f?p=18357:46 – Christian Shay Apr 30 '15 at 22:13
3

As of October 5th, 2015, the Oracle.ManagedDataAccess driver (ODAC 12c Release 4) supports ASO.

https://apex.oracle.com/pls/apex/f?p=18357:39:18138408495219::NO::P39_ID:28201

  • 1
    Just replaced the assembly in my application and it seems to be working. Thanks! The Oracle link doesn't work for me though. The nuget package can be found here: https://www.nuget.org/packages/Oracle.ManagedDataAccess/ – Greg Oct 20 '15 at 06:20
  • We get the same exception, but unfortunately updating Oracle.ManagedDataAccess.dll did not help us :( – nightcoder Oct 20 '15 at 22:08
  • Nightcoder, what do you see in your alert.log? May be a totally different issue depending on the error you find. – Christian Shay Oct 27 '15 at 05:29
2

Make sure that you do not have older versions of Oracle.ManagedDataAccess in the GAC. It seems that several versions of the dll have the same AssemblyVersion.

I had an older version in the CLR 4 GAC (C:\Windows\Microsoft.NET\assembly\GAC_MSIL for me) that got installed with a Oracle 12.1-client.

Since dll:s in the GAC always are used first the old ASO-uncapable version was used, but I thought that I used the newer version.

Solution was to uninstall the older version from the GAC. The first installation step in the 12.1.2400 Nuget Package Readme-file is to "Un-GAC and unconfigure any existing assembly".

1

Had some of the same problems. Found an entry in the registry: HKEY_LOCAL_MACHINE\SOFTWARE\wow6432\oracle. If this part contains a ODP.NET.managed entry, possible with another key (name version dependend) check if this entyr contains a string called TNS_ADMIN. This string should be deleted or the value changed to a not existing directory. If the string exists and point to a valid directory the Managed Client does not use the setting from the configuration file and fails. Further investigation should be used, but I got my stuff working, and must postpone the rest....

0

I too struggled with this error. Finally i tried with Oracle.ManagedDataAccess.dll for 12c (Version 4.122.1.0). Created a reference for above dll from the ODAC installed directory (\odp.net\managed\common), it worked...!!! Sharing my solution.

0

I had was getting this error, and it was a simple case that my query that I was running had a mistake.

Chris Hammond
  • 2,064
  • 5
  • 27
  • 53
  • The general solution for this error is: "Check the alert.log on the database server and investigate (google) any errors that occur there when you attempt to connect." – Christian Shay May 25 '19 at 12:51
  • Problem with that is the Oracle Estate is out of my control, if I need to see alert logs, I have to raise support request with the DBAs and then wait an eternity :( – Chris Hammond May 30 '19 at 08:40