The project was stopped for one year but I'm back.
I have read the
How To Configure Oracle Instant Client.
Lot of evolutions for this problem but it don't work yet...
The first problem was : I haven't understood that I needed an Oracle Instant Client !
In my sample, I have installed the instant client into C:\instantclient_12_1 directory.
I list here all the problems I have fixed :
- Download Oracle Instant Client : I'm on Windows 7 64 bits system but my C# project is compiled into x86 mode (32 bits) (see Generation / target plateform = x86 into project settings) : you must download the same target as the software that use it (for me 32 bits) !
- If you are working on 64 bits system and your software is in 32 bits, you must install registry keys into HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ and not into HKEY_LOCAL_MACHINE\SOFTWARE\ else it cannot found registry entry.
- Like explain into tutorial : add TNS_ADMIN = C:\instantclient_12_1 into environment variable.
- Your registry sample must be corrected ! All backslash has been lost !
Here the registry file to import (with Wow6432Node but you can remote it depending of your target plateform).
Code: Select all
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE]
"ORACLE_HOME"="C:\\instantclient_12_1"
@=""
"ORACLE_HOME_NAME"="OraHome"
"ORACLE_GROUP_NAME"="Oracle - OraHome"
"NLS_LANG"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\ALL_HOMES]
"HOME_COUNTER"="1"
"DEFAULT_HOME"="OraHome"
"LAST_HOME"="0"
@=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\ALL_HOMES\ID0]
"NAME"="OraHome"
"PATH"="C:\\instantclient_12_1"
"NLS_LANG"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\HOME0]
"ORACLE_HOME"="C:\\instantclient_12_1"
"ORACLE_SID"="ORCL"
"ID"="0"
"ORACLE_GROUP_NAME"="Oracle - OraHome"
"ORACLE_HOME_NAME"="OraHome"
"NLS_LANG"=""
"ORACLE_HOME_KEY"="Software\\ORACLE\\HOME0"
- I use a class derived from DbConfiguration. I must create a IManifestTokenResolver class into my derived DbConfiguration class constructor :
Code: Select all
public class DatabaseManagerFactoryConfiguration : DbConfiguration
{
public DatabaseManagerFactoryConfiguration()
{
SetManifestTokenResolver(new CManifestTokenResolverOracle());
}
}
internal sealed class CManifestTokenResolverOracle : IManifestTokenResolver
{
/// <summary>
/// The default token resolver.
/// </summary>
private static readonly IManifestTokenResolver DefaultManifestTokenResolver = new DefaultManifestTokenResolver();
public string ResolveManifestToken(DbConnection _dbConnection)
{
string strReturn;
if (here test if your are trying to connect in direct mode or not)
{ // Here : NOT DIRECT MODE
strReturn = "Oracle";//"Oracle, 11.2.0.1"; <-- Both seems working
}
else
{
strReturn = DefaultManifestTokenResolver.ResolveManifestToken(_dbConnection);
}
return strReturn;
}
}
I still have an error message :
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
Stack Trace :
à Devart.Data.Oracle.aq.a(b8 A_0, o A_1)
à Devart.Data.Oracle.OracleInternalConnection..ctor(b8 connectionOptions, OracleInternalConnection proxyConnection)
à Devart.Data.Oracle.ao.a(n A_0, Object A_1, DbConnectionBase A_2)
à Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, n A_1, DbConnectionBase A_2)
à Devart.Common.DbConnectionPoolGroup.a(DbConnectionPool A_0, DbConnectionBase A_1)
à Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
à Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection)
à Devart.Common.DbConnectionFactory.b(DbConnectionBase A_0)
à Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
à Devart.Common.DbConnectionBase.Open()
à Devart.Data.Oracle.OracleConnection.Open()
à Devart.Common.Entity.ae.a(DbConnection A_0)
à Devart.Data.Oracle.Entity.ay.a(OracleConnection A_0)
à Devart.Data.Oracle.Entity.OracleEntityProviderServices.GetDbProviderManifestToken(DbConnection connection)
à Devart.Data.Oracle.Entity.OracleEntityProviderServices.a(DbConnection A_0)
à Devart.Data.Oracle.Entity.OracleEntityProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection)
à System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection)
à System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase()
à System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection)
à System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
à System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
à System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
à System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update()
à DataManagerDAL.DataManagerFactory.ADatabaseManagerFactory.InitDatabaseModel() dans d:\Dev\Topobase2\DataManager\trunk\03-source\DataManager\DataManagerDAL\DataManagerFactory\ADatabaseManagerFactory.cs:ligne 200
à DataManagerDAL.DataManagerFactory.DatabaseManagerFactoryOracle.InitDatabaseModel() dans d:\Dev\Topobase2\DataManager\trunk\03-source\DataManager\DataManagerDAL\DataManagerFactory\DataManagerFactoryOracle.cs:ligne 199
à DataManagerDAL.DataManagerFactory.ADatabaseManagerFactory.SetConnectionInformations(Nullable`1 _connectionInformations) dans d:\Dev\Topobase2\DataManager\trunk\03-source\DataManager\DataManagerDAL\DataManagerFactory\ADatabaseManagerFactory.cs:ligne 268
à DataManager.DataManagerApp.OnStartup(StartupEventArgs _eStartupEvent) dans d:\Dev\Topobase2\DataManager\trunk\03-source\DataManager\DataManager\DataManagerApp.xaml.cs:ligne 151
Questions :
- Really need to add client folder to PATH ? It seem's to work without it
- What is missing ? Need to copy some ora files into C:\instantclient_12_1 folder ?I have tried but nothing is working !
If I found a solution, I'll reply here !
EDIT : I have found a way set the OracleConnectionStringBuilder server like :
Code: Select all
oraCSB.Server = String.Format("(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={0})(PORT={1}))(CONNECT_DATA=(SERVICE_NAME={2})))",
_connectionInformations.Value.Server,
_connectionInformations.Value.Port,
_connectionInformations.Value.Sid
);
Will try to understand.
Modifying Path is not needed !
Don't forget to set access to your user :
Code: Select all
GRANT change notification TO the_user;