views:

215

answers:

1

As noted by the question's title, I'm trying to connect to an Oracle database from a Windows service and I am getting the following error message:

System.Exception: OCIEnvNlsCreate failed with return code -1 but error message text was not available.

Other applications on the same computer are connecting to Oracle without any issues and I have tried running the service both as the Local System and using my own user credentials. Any ideas how to resolve this situation?

+1  A: 

This error occurs with several related problems, any one of which may be yours.

  1. You need to make sure the Enviornment variables oracle needs are set properly in your windows settings. Examples include TWO_TASK, TNS_ADMIN, and NLS_LANG.

  2. If you have multiple Oracle installations, your program may not be finding the correct ORACLE_HOME and the corresponding correct libraries (DLLs). Make sure you have the PATH and ORACLE_HOME set correctly as well.

Thomas Jones-Low
There are indeed multiple Oracle installations on my development machine, is there a workaround for that situation?
Rob
Go into Start Menu > Control Panel, select System applet. Under the Advanced tab there is a "Environment variables" button. This will let you set variables for you and the system. Make sure the ORACLE_HOME path is first on the PATH. You can set variables per user (like you or local system), but I don't know how to set them for Local System user. Ask the stack overflow brain trust.
Thomas Jones-Low
Thanks, since the question seems to be a bit more a long the lines of a system administration question I've gone and opened up a question on Serverfault - http://serverfault.com/questions/30283/how-do-i-set-the-oraclehome-variable-for-the-local-system-account - so we will see how things go.
Rob