I have moved a component of our application from a webservice to a Windows Service. It connects to oracle perfectly from the webservice but refuses to see the Tns names from the Windows service. I have given full control to the ORAHOME dir to the account the service is running under.
I have also checked the service account permission to the registry by using runas regedit as the service account and it can see HKLM\SOFTWARE\ORACLE\HOME0 details and HKLM\SOFTWARE\ORACLE\ALL_HOMES. All the ORACLE_HOME keys are pointing to the same directory.
I can log in as the service account and TNSPing the sid ‘UAT’ with no problems:
'OK (70 msec)'
I have attached process monitor to the process and the service account is (finally after scanning most of the registry) seeing the tnsnames.ora and even reads it.
Are you chuckling behind your keyboard? Can you help!
Cause: OracleException Source: System.Data.OracleClient Message: ORA-12154: TNS:could not resolve service name at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OracleClient.OracleConnection.Open()
First you can change the connection string to expand out the tns entry:
Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.161.50.101)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MOUAT)));Password=password;User Id=username;Then you get the real error:
And got ‘ORA-06413: Connection not open.’Which was due to the ‘Windows Service’ path having brackets in it ‘(DEV)’ or ‘(UAT)’
ANSWER: Expand out the connection string to exclude the TNS resolution and then make sure that the path to the calling application does not contain brackets ‘(‘ or ‘)’.