仅当作为服务运行时,ODP.NET ORA-12154 TNS错误 [英] ODP.NET ORA-12154 TNS error only when run as service

查看:414
本文介绍了仅当作为服务运行时,ODP.NET ORA-12154 TNS错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VB.NET中编写一项服务,以使用ODP.NET将数据连续记录到Oracle DB

该应用程序最初是作为基本的Windows Forms App编写的,并且可以运行,但是当我将其移植到服务时,它似乎看不到TNS文件,并抛出以下错误消息:

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

因此,在使用以下示例connectstring时

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

我收到ORA-12154

如果我直接向应用程序提供完整的TNS条目,例如

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

然后它可以工作,但是当我最初将该应用程序开发为Forms Application时,无论哪种方式都可以工作.

我认为环境变量可能设置不正确,但是我添加了必需的系统变量(ORACLE_HOME/TNS_ADMIN/将oracle文件夹添加到PATH),但这是行不通的.

正在运行/从中安装服务的路径不包含括号,我已经使用进程监视器检查了该进程,并且看起来它是使用正确的环境变量启动的(ORACLE_HOME/TNS_ADMIN/PATH都在这里和正确).用于测试的计算机正在运行Win XP

我在这里想念什么?

谢谢

我怀疑服务运行所在的用户将需要整个oracle目录树的文件系统权限.这感觉像是一个权限问题,因为它无法解析连接标识符,但是在不需要时可以起作用.

尝试为该服务运行的任何用户添加对整个oracle客户端目录的读取权限.

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

解决方案

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.

这篇关于仅当作为服务运行时,ODP.NET ORA-12154 TNS错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆