What can be the issue that .NET Framework 4.8 Console app fails to open a connection to Oracle instance when using DB alias only in Release mode. In Debug config app generates the report.
.NET app connection string to DB is
"Data Source=orcl;User Id=MyDB;Password=MyPWD;"
Also have another legacy app that works fine with this connection info.
As soon as I try localhost:1521/orcl.lan
as server in Release config, the app generates a report as expected. In Debug config, either server addresses work, localhost:1521/orcl.lan
or orcl
.
Logon method to Oracle is ported from legacy app and is as following:
private void applyOracleLogon(ReportDocument reportDoc, string dataBaseConnection)
{
var connectionElements = dataBaseConnection.Split(';');
string dataSource = connectionElements[0].Replace("Data Source=", "");
string databaseUser = connectionElements[1].Replace("User Id=", "");
string dataBasePassword = connectionElements[2].Replace("Password=", "");
ConnectionInfo tryInfo;
foreach(CrystalDecisions.CrystalReports.Engine.Table table in reportDoc.Database.Tables)
{
tryInfo = new ConnectionInfo();
TableLogOnInfo tableLogOnInfo = table.LogOnInfo;
tryInfo.Attributes = table.LogOnInfo.ConnectionInfo.Attributes;
tryInfo.Attributes.Collection.Set(DbConnectionAttributes.CONNINFO_DATABASE_DLL, "crdb_oracle.dll");
tryInfo.Attributes.Collection.Set("QE_DatabaseType", "Oracle Server");
tryInfo.Attributes.Collection.Set(DbConnectionAttributes.QE_DATABASE_NAME, string.Empty);
tryInfo.Attributes.Collection.Set(DbConnectionAttributes.QE_SERVER_DESCRIPTION, dataSource);
tryInfo.LogonProperties.Clear();
tryInfo.LogonProperties.Add(new NameValuePair2("Server", dataSource));
tryInfo.LogonProperties.Add(new NameValuePair2("Trusted_Connection", false));
tryInfo.ServerName = dataSource;
tryInfo.DatabaseName = string.Empty;
tryInfo.UserID = databaseUser;
tryInfo.Password = dataBasePassword;
tryInfo.IntegratedSecurity = false;
tableLogOnInfo.ConnectionInfo = tryInfo;
table.ApplyLogOnInfo(tableLogOnInfo);
//if (!table.TestConnectivity()) // returns false when in Release and server - orcl
//{
// Console.WriteLine("aaaa");
//}
}
}
CR for .NET runtime version – CR 13 SP33. Also have CR 2020 SP4 Patch 4 installed.
As well as latest Oracle Instant Client for 21c for both – 32 and 64 bit.
1