ODP.NET ORA-12154 TNS error only when run as service

人走茶凉 提交于 2019-12-10 16:36:58

问题


I am writing a service in VB.NET to continually log data to an Oracle DB using ODP.NET

The application was originally written as a basic Windows Forms App and works however when I port it to a service it seems it cannot see the TNS file and the following error message is thrown:

Service cannot be started. Oracle.DataAccess.Client.OracleException
ORA-12154:TNS:could not resolve the connect identifier specified    

So when using the following example connectstring

"Data Source= example;User Id= user;Password=password;"

I get ORA-12154

If I provide the full TNS entry directly to the app e.g

"Data Source= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = EXAMPLE)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = EXAMPLE) ) );User Id= user;Password=password;"

Then it works but when I originally developed the app as a Forms Application it worked either way.

I assumed maybe the environment variables were not set up correctly but I have added the required system variables (ORACLE_HOME / TNS_ADMIN / added the oracle folder to PATH) and it doesnt work.

The path the service is being run/was installed from does not contain parentheses, I have checked the process with process monitor and it looks like it is being started up with the correct environment variables (ORACLE_HOME / TNS_ADMIN / PATH are all there and correct). The machine being used for testing is running Win XP

What am I missing here?

Thanks


回答1:


I suspect that the user that the service runs as will need file system permission to the entire oracle directory tree. This feels like a permissions problem, since it can't resolve the connect identifier, but works if it doesn't need to.

Try adding read permission to the entire oracle client directory for whatever user that the service is running as.



来源:https://stackoverflow.com/questions/13309702/odp-net-ora-12154-tns-error-only-when-run-as-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!