title: ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file
body: <h1>Overview</h1>
  
  <p>I want to replace Oracle.DataAccess with Orcale.<strong>Managed</strong>DataAccess, but opening a connection with the latter throws an <em>ORA-12537 network session end of file</em> exception.</p>
  
  <p>Exception message / stack trace</p>
  
  <blockquote>
    <p>{OracleInternal.Network.NetworkException (0x000030F9): <strong>ORA-12537</strong>: 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()}</p>
  </blockquote>
  
  <p>I am trying to connect to a Oracle 11g database and do not have a client installed on my local machine.</p>
  
  <h1>Working test application (unmanaged)</h1>
  
  <p>Using Oracle.DataAccess <strong>works fine</strong>.</p>
  
  <pre class="lang-cs prettyprint-override"><code>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();
          }
      }
  }
  </code></pre>
  
  <h3>References and dependencies</h3>
  
  <ul>
  <li>Oracle.DataAccess (2.111.7.0)</li>
  <li>oci.dll (11.1.0.1)</li>
  <li>orannzsbb11.dll (11.1.0.6)</li>
  <li>oraociei11.dll (Oracle Call Interface Instant Client)</li>
  <li>OraOps11w.dll (2.111.7.0)</li>
  </ul>
  
  <h3>Project settings</h3>
  
  <p>Plattform target <strong>x86</strong><br>
  Target Framework 4.5</p>
  
  <h1>Failing test application (managed)</h1>
  
  <p>Using the nuget package <em>Official Oracle ODP.NET, Managed Driver
  12.1.21</em></p>
  
  <p>Code is identical to above. Only change:</p>
  
  <pre class="lang-cs prettyprint-override"><code>using System;
  using Oracle.ManagedDataAccess.Client;
  //... rest the same as above
  </code></pre>
  
  <h3>References and dependencies</h3>
  
  <p>Only:</p>
  
  <ul>
  <li>Oracle.ManagedDataAccess (4.121.2.0)</li>
  </ul>
  
  <h3>Project settings</h3>
  
  <p>Plattform target <strong>Any CPU</strong><br>
  Target Framework 4.5</p>
  
  <h3>App.config</h3>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /&gt;
    &lt;/configSections&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /&gt;
    &lt;/startup&gt;
    &lt;system.data&gt;
      &lt;DbProviderFactories&gt;
        &lt;remove invariant="Oracle.ManagedDataAccess.Client" /&gt;
        &lt;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" /&gt;
      &lt;/DbProviderFactories&gt;
    &lt;/system.data&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;publisherPolicy apply="no" /&gt;
          &lt;assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.121.2.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
    &lt;oracle.manageddataaccess.client&gt;
      &lt;version number="*"&gt;
        &lt;dataSources&gt;
          &lt;!--&lt;dataSource alias="MyDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=1.2.3.4)(PORT=1521))(CONNECT_DATA=(SID=sid01)))" /&gt;--&gt;
        &lt;/dataSources&gt;
        &lt;settings&gt;
          &lt;!--&lt;setting name="SQLNET.AUTHENTICATION_SERVICES" value="NTS"/&gt;--&gt;
        &lt;/settings&gt;
      &lt;/version&gt;
    &lt;/oracle.manageddataaccess.client&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I have tried different settings (NTS, none, all) and changed the connection string to <em>User Id=XXX;password=XXX;Data Source=MyDataSource;</em>, but the error stays the same.</p>
  
  <h1>Questions</h1>
  
  <ul>
  <li>What could be causing the  <em>ORA-12537 network session end of file</em> exception?</li>
  <li>Is a reference / dependency missing?</li>
  <li>Does something have to be configured on the DB server?</li>
  </ul>
  
  <h1>UPDATE</h1>
  
  <p>On the server we are getting an <strong>ORA-12679: Native services disabled by other process but required</strong> error in the alert.log.</p>
  
  <p>It seems to have something to do with the encryption. Commenting out the following lines in the servers sqlnet.ora solves the issue.</p>
  
  <pre><code>#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)))
  </code></pre>
  
  <h2>New question</h2>
  
  <p>How do we configure ManagedDataAccess so it works with the encryption?</p>
  
  <h1>Update 2</h1>
  
  <p>Seems to work now with ODP Managed Driver 12c:<br>
  <a href="https://www.nuget.org/packages/Oracle.ManagedDataAccess/">https://www.nuget.org/packages/Oracle.ManagedDataAccess/</a></p>