"Invalid service name" and "Can not load oci.dll" troubles

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
chiccodoro
Posts: 7
Joined: Thu 15 Sep 2011 09:35

"Invalid service name" and "Can not load oci.dll" troubles

Post by chiccodoro » Mon 26 Sep 2011 11:26

We are trying to connect our application to an Oracle database:

1. When trying to connect using direct mode with the correct host and service name, we got an "Invalid service name" error message. We created a tiny console application to verify that. The connection string looked like this:

Code: Select all

User Id=theuser;Password=thepassword;Server=the.fqdn.of.the.host;Direct=True;Service name=theservicename
As a workaround we installed an instantclient and tried the following indirect connection, which worked:

Code: Select all

User Id=theuser;Password=thepassword;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=the.fqdn.of.the.host)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=theservicename)));Direct=False
2. Since the indirect connection worked in the console application we then used this as the connection string in our web.config. The web application though failed to connect:

Code: Select all

Can not load Oracle client library oci.dll from home .   at Devart.Data.Oracle.OracleHome.get_ClientVersion()
   at Devart.Data.Oracle.aw.a(Boolean A_0, Boolean A_1, OracleHome A_2, Boolean A_3)
   at Devart.Data.Oracle.OracleInternalConnection..ctor(aa connectionOptions, OracleInternalConnection proxyConnection)
   at Devart.Data.Oracle.cs.a(l A_0, Object A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, l A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection)
   at Devart.Common.DbConnectionFactory.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
   at Devart.Common.DbConnectionBase.Open()
   at Devart.Data.Oracle.OracleConnection.Open()
   at Devart.Common.Entity.b7.a(DbConnection A_0)
   at Devart.Data.Oracle.Entity.j.a(OracleConnection A_0, Boolean A_1)
   at Devart.Data.Oracle.Entity.OracleEntityProviderServices.GetDbProviderManifestToken(DbConnection connection)
   at System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
Somewhere on the forum I read that the reason could be a limited trust level. But I tried using , and it still did not work.

I also added a test aspx page which executes the following code, and the page was successful.

Code: Select all




It printed: C:\oracle\product\11.2.0\client_1\oci.dll InternalName: OriginalFilename: Oci.dll FileVersion: 11.2.0.1.0 Production FileDescription: Oracle Call Interface Product: ProductVersion: Debug: False Patched: False PreRelease: False PrivateBuild: False SpecialBuild: False Language: English (United States)

If you can help me solve this, I will be glad. I will be even more happy if I could resolve the first of these issues, such as not to need the instant client at all.

Thanks,
chiccodoro

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 29 Sep 2011 08:20

chiccodoro wrote:1. When trying to connect using direct mode with the correct host and service name, we got an "Invalid service name" error message.
Could you please try using the SID connection string parameter (to specify database instance name) instead of setting Service Name? Does it work in this case?
http://www.devart.com/dotconnect/oracle ... tring.html
chiccodoro wrote:2. Since the indirect connection worked in the console application we then used this as the connection string in our web.config. The web application though failed to connect:

Code: Select all

Can not load Oracle client library oci.dll from home
...
As we understood, oci.dll is available in the C:\oracle\product\11.2.0\client_1\ folder on your syste, isn't it? Make sure that C:\oracle\product\11.2.0\client_1\; is placed on the first place in your system variable PATH (Control Panel > System and Security > System > System Properties > Advanced > Environment Variables).

chiccodoro
Posts: 7
Joined: Thu 15 Sep 2011 09:35

Post by chiccodoro » Fri 30 Sep 2011 10:10

Shalex, thank you for your reply.
Shalex wrote:Could you please try using the SID connection string parameter?
Indeed, with the SID a direct connection works! On the other hand, this cannot be the eventual solution because we use racks, and the SID denotes one specific node which undermines load balancing. In fact, we would prefer to use a TNS name to connect to Oracle, but that isn't supported by Direct mode. So I would still be glad to solve the OCI access issue.
Shalex wrote:As we understood, oci.dll is available in the C:\oracle\product\11.2.0\client_1\ folder on your syste, isn't it? Make sure that C:\oracle\product\11.2.0\client_1\; is placed on the first place in your system variable PATH (Control Panel > System and Security > System > System Properties > Advanced > Environment Variables).
Yes, C:\oracle\product\11.2.0\client_1\ is placed in the the first place. And the console application is able to connect to the database. Only the web application isn't.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 05 Oct 2011 13:11

chiccodoro wrote:Indeed, with the SID a direct connection works! On the other hand, this cannot be the eventual solution because we use racks, and the SID denotes one specific node which undermines load balancing. In fact, we would prefer to use a TNS name to connect to Oracle, but that isn't supported by Direct mode. So I would still be glad to solve the OCI access issue.
When Service Name is specified and implies several database instances, dotConnect for Oracle connects to the first instance provided by Oracle listener. Note that RAC is not supported in the Direct mode, and provider works only with this one database instance.
chiccodoro wrote:

Code: Select all

Can not load Oracle client library oci.dll from home
...
Try the following: right click on the C:\oracle\product\11.2.0\client_1 folder > Properties > Security and grant access to the user "Everyone".

chiccodoro
Posts: 7
Joined: Thu 15 Sep 2011 09:35

Post by chiccodoro » Tue 11 Oct 2011 10:54

Shalex wrote:Try the following: right click on the C:\oracle\product\11.2.0\client_1 folder > Properties > Security and grant access to the user "Everyone".
I tried that without any success.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 12 Oct 2011 07:41

Make sure that the mode (x86 or x64), in which your application is executed, corresponds to the capacity of your Oracle client. You can check the mode of your application in Windows Task Manager (the Processes tab).

chiccodoro
Posts: 7
Joined: Thu 15 Sep 2011 09:35

Post by chiccodoro » Tue 18 Oct 2011 14:34

Shalex wrote:Make sure that the mode (x86 or x64), in which your application is executed, corresponds to the capacity of your Oracle client. You can check the mode of your application in Windows Task Manager (the Processes tab).
We run our application on a 64 bit Windows Server 2008 R2 and have installed a 64 bit Oracle InstantClient.

I took a look at the process list in task manager. The "w3wp.exe" service was not marked as 32 bit.

I checked the "Advanced Settings" of the IIS ASP.NET v4.0 app pool which is used by our application. The "Enable 32-Bit Applications" flag is false. When I set it to "true", I get a different error message:

Code: Select all

Can not obtain Oracle client information from registry. Make sure that Oracle Client Software is installed, or use Direct mode of connecting to server.   at Devart.Data.Oracle.OracleHomeCollection.a()
   at Devart.Data.Oracle.OracleInternalConnection..ctor(aa connectionOptions, OracleInternalConnection proxyConnection)
   at Devart.Data.Oracle.cs.a(k A_0, Object A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, k A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection)
   at Devart.Common.DbConnectionFactory.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
   at Devart.Common.DbConnectionBase.Open()
   at Devart.Data.Oracle.OracleConnection.Open()
   at Devart.Common.Entity.b7.a(DbConnection A_0)
   at Devart.Data.Oracle.Entity.j.a(OracleConnection A_0, Boolean A_1)
   at Devart.Data.Oracle.Entity.OracleEntityProviderServices.GetDbProviderManifestToken(DbConnection connection)
   at System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)

chiccodoro
Posts: 7
Joined: Thu 15 Sep 2011 09:35

Home not defined?

Post by chiccodoro » Tue 18 Oct 2011 15:10

I noticed that the (original) error message has a space followed by period. Could this mean that it would usually mention the name of the Oracle home, but the name is an empty string?

Code: Select all

Can not load Oracle client library oci.dll from home .
   at Devart.Data.Oracle.OracleHome.get_ClientVersion()
   at Devart.Data.Oracle.av.a(Boolean A_0, Boolean A_1, OracleHome A_2, Boolean A_3)
   at Devart.Data.Oracle.OracleInternalConnection..ctor(aa connectionOptions, OracleInternalConnection proxyConnection)
   at Devart.Data.Oracle.cs.a(k A_0, Object A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, k A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection)
   at Devart.Common.DbConnectionFactory.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
   at Devart.Common.DbConnectionBase.Open()
   at Devart.Data.Oracle.OracleConnection.Open()
   at Devart.Common.Entity.b7.a(DbConnection A_0)
   at Devart.Data.Oracle.Entity.j.a(OracleConnection A_0, Boolean A_1)
   at Devart.Data.Oracle.Entity.OracleEntityProviderServices.GetDbProviderManifestToken(DbConnection connection)
   at System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
Could it be that dotConnect is not able to resolve the home and thus doesn't even know the right path to get to the client? This would explain why the test code snipped accessing the file directly by specifying the absolute file path explicitely works while the devart driver doesn't.

I verified that ORACLE_HOME is set in the environment variables. When I had a look at the registry, it looked as follows:

Code: Select all

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
|
+-- KEY_OraClient11g_home1
    +-- NLS_LANG = "AMERICAN_AMERICA.WE8MSWIN1252"
    +-- ORACLE_GROUP_NAME = "Oracle - OraClient11g_home1"
    +-- ORACLE_HOME = "C:\oracle\product\11.2.0\client_1"
    +-- ORACLE_HOME_NAME = "OraClient11g_home1"
    +-- TNS_ADMIN = "C:\oracle\product\11.2.0\client_1\network\admin"
In particular, there is no ALL_HOMES key.

I tried and added the following, then restarted the app pool and web site. But I still got the same error messages:

Code: Select all

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
|
+-- ALL_HOMES
    +-- DEFAULT_HOME = "OraClient11g_home1"
    +-- HOME_COUNTER = "1"
    +-- LAST_HOME = "0"
    +-- ID0
        +-- NLS_LANG = "AMERICAN_AMERICA.WE8MSWIN1252"
        +-- PATH = "C:\oracle\product\11.2.0\client_1"
        +-- NAME = "OraClient11g_home1"
What is required in addition to an 11g 64bit InstantClient xcopy installation?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 20 Oct 2011 15:45

Here are peculiarities of using the InstantClient installation type of Oracle client:
1. The instantclient libraries should be put into the same folder where the assembly of your application resides.
2. The application should have permission on unmanaged modules loading.

Is it possible for you to choose the "Administrator" type of Oracle client installation instead of InstantClient?

chiccodoro
Posts: 7
Joined: Thu 15 Sep 2011 09:35

Post by chiccodoro » Tue 25 Oct 2011 12:46

Shalex wrote:Is it possible for you to choose the "Administrator" type of Oracle client installation instead of InstantClient?
Hi Shalex, I have now installed the Administrator type client, and this fixed it! Thank you for your assistance.

Post Reply