Wednesday, November 18, 2009

Trying to resolve ODP error

Getting this error
The type 'Oracle.DataAccess.Client.OracleConnection' exists in both 'c:\WINDOW\assembly\GAC_32\Oracle.DataAccess\\Oracle.DataAccess.dll' and 'c:\WINDOWS\assembly\GAC\Oracle.DataAccess\\Oracle.DataAccess.dll'

It goes on for Oracle.DataAccess.Client.OracleCommand, OracleDataAccess.Client.OracleDataAdapter

Read somewhere need to ungac one of them via
gacutil /u Policy.2.102.Oracle.DataAccess

Need to run gacutil from Visual Studio 2008 command prompt

More details how to run gacutil
I believe the version numbers changed a bit with the 10.2 release. It sounds to me like you still have the old Oracle.DataAccess.dll file referenced in the GAC. What I would try is to remove all references that are in the GAC using the gacutil that comes with the .NET Framework 2.0 SDK. If you use the .NET 1.1 gacutil, you'll get an error when trying to work with the .NET 2.0 DLL's. To remove the references, you'll have to execute something like this:

REM Remove GAC Entries
gacutil /u Oracle.DataAccess
gacutil /u Policy.9.2.Oracle.DataAccess
gacutil /u Policy.10.1.Oracle.DataAccess
gacutil /u Policy.10.2.Oracle.DataAccess

This will remove all your GAC entries, including the policies.

Then, add the references from the new ODP.NET like this:

REM Update .NET GAC (1.1 and 2.0)
gacutil.exe /i \Client\\\bin\1.x\Oracle.DataAccess.dll /f
gacutil.exe /i \Client\\\bin\2.x\Oracle.DataAccess.dll /f
gacutil.exe /i \Client\\\PublisherPolicy\1.x\Policy.9.2.Oracle.DataAccess.dll
gacutil.exe /i \Client\\\PublisherPolicy\1.x\Policy.10.2.Oracle.DataAccess.dll

where = The path to your Oracle Home

These commands will add the references to the GAC for .NET 1.1 and 2.0. Also, if you have tools built with references to the previous versions, the Policy entries will direct those references to use the latest library. You may be able to omit the install of the Policy.9.2.Oracle.DataAccess.dll if you have never used the Oracle 9.2 version ODP.NET in any of your tools.

I actually got most of this procedure from an Oracle document somewhere, but I can't seem to find it right now. It might be in an FAQ somewhere...

Finally the solution for me after a week of search and destroy
Check your references in web.config of the application, or machine.config/web.config of the machine. You have references to two versions of the dll, so remove the one you are not going to use.

No comments:

Post a Comment