Problem with Windows Service that connect to Oracle

25. September 2012 13:38 by Mrojas in   //  Tags: , , , ,   //   Comments (0)

Today Joseph was creating a windows service, which had an schedule task to execute something on an Oracle Server.

Everything worked out of the Windows Service but as soon as he added it to the Windows Service, it fail.

He suspected it had something to do with the 64 bit platform so he made sure to compile for AnyCPU, but it did not work...

Answer: It was the OracleClient fault. The OracleClient for ADO.NET do not work for AnyCPU. You need to use the 64 or 32 bit version.

 

ORA-12154: TNS:could not resolve the connect identifier specified for asp.net application to oracle

18. November 2010 16:57 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)

I had a Windows Server 2003 and I was trying to connect to Oracle with the System.Data.OracleClient provider.

I was able to connect from a console application but not from ASP.NET.
From ASP.NET I only got ORA-12154 errors.

I found that on Windows 2003 Server, ASP.NET applications run in the
security context of the “Network Service” user.

So I tried these two  things:

I first started following these steps:
1. Log on to Windows as a user with Administrator privileges.
2. Launch Windows Explorer from the Start Menu and and navigate to the
ORACLE_HOME folder. It is usually under the oracle instalation folder.
In my case that is C:\oracle\product\10.2.0\client_1
3. Right-click on the ORACLE_HOME folder and choose the "Properties" option
from the drop down list. A "Properties" window should appear.
4. Click on the "Security" tab of the "Properties" window.
5. Click on "Authenticated Users" item in the "Name" list (on Windows XP
the "Name" list is called "Group or user names").
6. Uncheck the "Read and Execute" box in the "Permissions" list under the
"Allow" column (on Windows XP the "Permissions" list is called
"Permissions for Authenticated Users").
7. Re-check the "Read and Execute" box under the "Allow" column (this is
the box you just unchecked).
8. Click the "Advanced" button and in the "Permission Entries" list make
sure you see the "Authenticated Users" listed there with:
Permission = Read & Execute
Apply To = This folder, subfolders and files
If this is NOT the case, edit that line and make sure the "Apply onto"
drop-down box is set to "This folder, subfolders and files". This
should already be set properly but it is important that you verify this.
9. Click the "Ok" button until you close out all of the security properties
windows. The cursor may present the hour glass for a few seconds as it
applies the permissions you just changed to all subfolders and files.
10. Reboot your computer to assure that these changes have taken effect.
(I thought that rebooting was not that important but it seems that you have to reboot to make changes effective)

It sometimes happens that it is not enough, because it seems that some oracle installations need the
the ASP.NET process to run with an account with sufficient privileges.

The second thing you can do in that case is.

1. First open the machine.config file. That will be usually in %windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config

2. Look for something like:

<system.web>
    <processModel autoConfig="true" />

3. Add the userName=”System” attribute. For example

<processModel autoConfig="true" userName="System" />

4. Restart the IIS.

No more System.Data.OracleClient

7. August 2009 06:15 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)

 Microsoft announced that they won’t support the System.Data.OracleClient anymore :(

 

The message says that it will still be available in .NET 4.0 but “deprecated” and that it wont impact existing applicatoions.

 

So what are my options?

Well you have to go to a third party. Not now but eventually.

 

Oracle Data Provider for .NET (ODP.NET) (Oracle states that ODP.NET is Free)

DataDirect ADO.NET Provider for Oracle

dotConnect for Oracle

 

Migration to ODP.NET

Installation

Microsoft OracleClient to ODP.NET Application Migration: Code Migration

Oracle provide general instructions. In summary you need to:

  1. Add the references to Oracle.DataAccess
  2. Change namespaces: System.Data.OracleClient by  Oracle.DataAccess.Client; and maybe add “using Oracle.DataAccess.Types”
  3. Update the connection String (most attributes are the same). Change Integrated Security by  "User Id=/", change “Server” attribute to “Data Source” and remove Unicode
  4. The following is anoying but you have to add after all OracleCommands something like OracleCommand1.BindByName = true;

Deployment

  • Oracle Universal Installer (either in normal installation or Silent Install)
  • XCopy (I like this :) ) just remember to download the ODAC xcopy version

Categories