We have a decade old web forms application which uses Enterprise Library 5.0.414.0 with Oracle.DataAccess.dll (4.112.) to connect to our Oracle DB, and this worked flawlessly until recently. With the removal of VC++ 2012 REDISTRIBUTABLE in our servers, we are now compelled to use the Enterprise Library 6.0 with oracle.manageddataaccess.dll (v19.1 upwards) as the earlier version had a strong reference to Oracle.DataAccess.dll (4.112.).
I have a test application using the Enterprise Library 6.0 with the Oracle.ManagedDataAccess.dll (19.1 version). This seems to be working fine. However, I had 2 issues observed:
- Using wallets did not work. However, the same works when i provide the user id and password
- when providing “Proxy User ID”, “Validate Connection” etc, error was thrown saying that the keyword was not supported.
On investigating further, I observed that internally, the provider being used is still “System.Data.OracleClient” and not “Oracle.ManagedDataAccess.Client” and hence the reason for the issues.
The following is my web.config entry
<configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>
</configSections>
<dataConfiguration defaultDatabase="6083">
<providerMappings>
<add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data"
name="Oracle.ManagedDataAccess.Client" />
</providerMappings>
</dataConfiguration>
<connectionStrings>
<clear />
<add providerName="Oracle.ManagedDataAccess.Client" name="conn1" connectionString="Data Source=DS_1;Password=PWD1;User ID=USER1;"/>
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<publisherPolicy apply="no" />
<assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<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.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
<appSettings>
<add key="useODPNET" value="Y" />
<add key="wrappertype" value="1" />
</appSettings>
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<setting name="TNS_ADMIN" value="<PATH_TO_TNS>" />
</settings>
</version>
</oracle.manageddataaccess.client>
</configuration>
This is the sample class that i am using
public class DataAccessWrapper : IDBWrapper
{
static DataAccessWrapper()
{
DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
}
public List<errorinfo> GetErrors()
{
var database = DatabaseFactory.CreateDatabase();//THE DBFACTORY IS ALWAYS System.Data.OracleClient
List<errorinfo> errors = new List<errorinfo>();
using (var conn = database.CreateConnection())
{
conn.Open();
using (DbCommand command = conn.CreateCommand())
{
command.CommandText = "SELECT * FROM SOME_TABLE WHERE DATETIME >= sysdate - 20 ORDER BY 1 DESC";
command.CommandType = System.Data.CommandType.Text;
var reader = command.ExecuteReader();
while (reader.Read())
{
var i = reader["ERRORLOG_ID"].ToString();
var j = reader["LOGGER"].ToString();
errors.Add(new errorinfo(i, j));
Console.WriteLine(i);
Console.WriteLine(j);
}
}
}
return errors;
}
}
The same code (except for the addition of SetDatabaseProviderFactory in the constructor) when run using the previous EntLib 5.0.414 was returning Oracle.DataAccess.Client related objects. In this case, its always OracleClient, even though the connectionstring has been set accordingly. Am I missing something here? Please advise, guide.