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.
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();
}
}
}
Plattform target x86
Target Framework 4.5
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
Only:
Plattform target Any CPU
Target Framework 4.5
<?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.
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)))
How do we configure ManagedDataAccess so it works with the encryption?
Seems to work now with ODP Managed Driver 12c:
https://www.nuget.org/packages/Oracle.ManagedDataAccess/
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With