Differences between LLBLGen and System.Data.Common.DbConnection for Oracle?

Posts   
 
    
ErinaG
User
Posts: 24
Joined: 31-Dec-2014
# Posted on: 10-Nov-2020 14:44:31   

We have a customer that is running our executable on a machine that does not have Oracle installed. Instead they are dropping the Oracle.ManagedDataAccess.dll into the executable directory and adding connection settings to the app.config like this:

<connectionStrings>
  <add name="FrameworkConnection" connectionString="Data Source=(DESCRIPTION=(ENABLE=BROKEN)
    (ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.x)(PORT=xxx)
                           (HOST=x.x.x.x)(PORT=xxx)
                           (HOST=x.x.x.x)(PORT=xxx)
                           (HOST=x.x.x.x)(PORT=xxx))
  (CONNECT_DATA=(SERVICE_NAME=xxx.xxx.xxx.com)));User Id=xxx;Password=xxx;" providerName="Oracle.ManagedDataAccess.Client" />
</connectionStrings>

<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>

We have run tests on our own machines and confirmed that this works correctly. However, the customer is running into an odd issue. In the first part of our program, we connect to the database using a System.Data.Common.DbConnection, then later in the program we use an LLBLGen adapter. It seems as though the System.Data.Common.DbConnection is working without issue, but the program is crashing when it gets to the LLBLGen connection.

Works correctly:

System.Data.Common.DbProviderFactory databaseProviderFactory = System.Data.Common.DbProviderFactories.GetFactory("Oracle.ManagedDataAccess.Client");
System.Data.Common.DbConnection connection1 = databaseProviderFactory.CreateConnection();
connection1 .ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["FrameworkConnection"].ConnectionString;
...
System.Data.Common.DbCommand command1 = connection1.CreateCommand();
...
command1.ExecuteScalar();

Crashes:

SD.LLBLGen.Pro.ORMSupportClasses.IDataAccessAdapter adapter = new Grb.Platform.Framework.Business.Lower.Oracle.DatabaseSpecific.DataAccessAdapter(connection1.ConnectionString.ConnectionString, false, null, null);
adapter.OpenConnection();

Stack Trace:

The following exception occurred at System.Net.IPHostEntry GetAddrInfo(System.String):
No such host is known

The following exception occurred at Void DoConnect(System.String):
ORA-12545: Network Transport: Unable to resolve connect hostname

The following exception occurred at PR Get(OracleInternal.ConnectionPool.ConnectionString, Boolean, Oracle.ManagedDataAccess.Client.OracleConnection, System.String, Boolean):
ORA-12545: Network Transport: Unable to resolve connect hostname

...

Stack Trace:
  at System.Net.Dns.GetAddrInfo(String name)
  at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
  at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
  at OracleInternal.Network.TcpTransportAdapter.Connect(ConnectionOption conOption)   at OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor)
  at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, OracleConnection connRefForCriteria, String instanceName)   at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
  at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
  at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
  at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
  at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.OpenConnection()
  at Grb.Platform...

We are unable to recreate this on our test machines. Is the way LLBLGen connects to Oracle any different from how a System.Data.Common.DbConnection does it? We are using LLBLGen 5.6.2.0. Any insight would be appreciated.

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 10-Nov-2020 17:51:50   

Are you sure LLBLGen is using the same connectionString, shown above?

ErinaG
User
Posts: 24
Joined: 31-Dec-2014
# Posted on: 10-Nov-2020 21:57:29   

Yes, absolutely.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Nov-2020 07:18:07   

What LLBLGen version are you using?

Could you please try this ?

<add key="ODPNETAlwaysChooseUnmanagedProvider" value="true"/>

... also check this documentation link

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 11-Nov-2020 10:01:27   

The stacktrace shows the managed provider is used, so I don't think that's it. The adapter correctly creates a connection, and opens it it seems, but the OracleConnection can't reach the host specified in the connection string. I still think the connection string is the problem.

The test program that works reads the connection string directly. Could you check the ConnectionString property after creating the DataAccessAdapter, what its value is, to see what it uses?

Frans Bouma | Lead developer LLBLGen Pro
ErinaG
User
Posts: 24
Joined: 31-Dec-2014
# Posted on: 11-Nov-2020 15:20:21   

When I debug on my machine, the DataAccessAdapter is using the connection string from the config:

Data Source=(DESCRIPTION=(ENABLE=BROKEN)
      (ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.x)(PORT=xxxx)
                             (HOST=x.x.x.x)(PORT=xxxx)
                             (HOST=x.x.x.x)(PORT=xxxx)
                             (HOST=x.x.x.x)(PORT=xxxx))
    (CONNECT_DATA=(SERVICE_NAME=xxx.xxx.xxx.com)));User Id=xxx;Password=xxx;

But again, testing it on my machine works as expected.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 12-Nov-2020 08:49:49   

So it might be helpful to write the connectionstring you get from the property in the adapter at the site where things go wrong to a file or something to see what's wrong. The stacktrace suggests the odp.net objects are created correctly, it just can't connect to the right server.

Frans Bouma | Lead developer LLBLGen Pro