Oracle.DataAccess.Client Error

1

Background: This website use oracle and spring.net.
version of the Oracle.DataAccess: 4.112.2.0
version of the Spring: 1.3.2.40943

Webconfig file

<db:provider id="SDDbProvider" provider="Oracle.DataAccess.Client"
           connectionString="User Id=****; Password = *****; Data Source = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=****)(PORT=****))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=*****)))" />

This is working fine in debug mode. And I publish this website on local IIS (7.5) & which is also working fine. But when I copy the published folder to a remote server (also runs IIS 7.5) it gives the folowing errror.

Note: I checked the bin in published folder and it has all the necessary DLL for Oracle

oci
ociw32
Oracle.DataAccess
orannzsbb11
oraocci11
oraociei11
OraOps11w

Error thrown by a dependency of object 'Oracle.DataAccess.Client' defined in 'assembly [Spring.Data, Version=1.3.2.40943, Culture=neutral, PublicKeyToken=65e474d141e25e07], resource [Spring.Data.Common.dbproviders.xml] line 400' : Unsatisfied dependency expressed through constructor argument with index 2 of type [System.Type] : Could not convert constructor argument value [Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342] to required type [System.Type] : Cannot convert property value of type [System.String] to required type [System.Type] for property ''.
while resolving 'constructor argument with name dbmetadata' to 'Spring.Data.Common.DbMetadata#195EA5D' defined in 'assembly [Spring.Data, Version=1.3.2.40943, Culture=neutral, PublicKeyToken=65e474d141e25e07], resource [Spring.Data.Common.dbproviders.xml] line 400' 


[UnsatisfiedDependencyException: Error thrown by a dependency of object 'Oracle.DataAccess.Client' defined in 'assembly [Spring.Data, Version=1.3.2.40943, Culture=neutral, PublicKeyToken=65e474d141e25e07], resource [Spring.Data.Common.dbproviders.xml] line 400' : Unsatisfied dependency expressed through constructor argument with index 2 of type [System.Type] : Could not convert constructor argument value [Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342] to required type [System.Type] : Cannot convert property value of type [System.String] to required type [System.Type] for property ''.
 while resolving 'constructor argument with name dbmetadata' to 'Spring.Data.Common.DbMetadata#25C456C' defined in 'assembly [Spring.Data, Version=1.3.2.40943, Culture=neutral, PublicKeyToken=65e474d141e25e07], resource [Spring.Data.Common.dbproviders.xml] line 400']
   Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolveInnerObjectDefinition(String name, String innerObjectName, String argumentName, IObjectDefinition definition, Boolean singletonOwner) +385
   Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolvePropertyValue(String name, IObjectDefinition definition, String argumentName, Object argumentValue) +278
   Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolveValueIfNecessary(String name, IObjectDefinition definition, String argumentName, Object argumentValue) +19
   Spring.Objects.Factory.Support.ConstructorResolver.ResolveConstructorArguments(String objectName, RootObjectDefinition definition, ObjectWrapper wrapper, ConstructorArgumentValues cargs, ConstructorArgumentValues resolvedValues) +1385
   Spring.Objects.Factory.Support.ConstructorResolver.GetConstructorInstantiationInfo(String objectName, RootObjectDefinition rod, ConstructorInfo[] chosenCtors, Object[] explicitArgs) +218
   Spring.Objects.Factory.Support.ConstructorResolver.AutowireConstructor(String objectName, RootObjectDefinition rod, ConstructorInfo[] chosenCtors, Object[] explicitArgs) +79
   Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.CreateObjectInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments) +278
   Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure) +1204
   Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectInternal(String name, Type requiredType, Object[] arguments, Boolean suppressConfigure) +2216
   Spring.Objects.Factory.Support.AbstractObjectFactory.GetObject(String name, Type requiredType) +21
   Spring.Data.Common.DbProviderFactory.GetDbProvider(String providerInvariantName) +81
   Spring.Data.Common.DbProviderFactoryObject.CreateProviderInstance() +18
   Spring.Data.Common.DbProviderFactoryObject.GetObject() +205
   Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectFromFactoryObject(IFactoryObject factory, String objectName, RootObjectDefinition rod) +98

[ObjectCreationException: Error creating object with name 'SDDbProvider' : FactoryObject threw exception on object creation.]
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +4649821
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +325
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375

[HttpException (0x80004005): Error creating object with name 'SDDbProvider' : FactoryObject threw exception on object creation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11529072
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4784373

Any idea why this is happening? Has it something to do with GAC in the remote server? Thanks

.net
oracle
spring
spring.net
asked on Stack Overflow May 14, 2013 by Hello World

4 Answers

5

I fixed this issue after a week I guess. Thought to share my experience.

First, This error message related to Spring framework. Based on the DBprovider we specify on our config file (in my case it's Oracle.DataAccess.Client), Spring.Data DLL tries to resolve the database provider. (More about Spring dbproviders)

It uses the resource file (Spring.Data.Common.dbproviders.xml) to resolve this. Error thrown from the following line in the dbproviders.xml file. (File location: Spring.Net/src/Spring/Spring.Data/Data/Common/dbproviders.xml)

 <constructor-arg name="connectionType" value="Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342"/>

For some reason dbproviders.xml try to find the Oracle.DataAccess DLL in the GAC (windows/assembly/GAC). According to my experience it doesn't look in the bin folder. If it can't find the DLL in GAC, it throws the above error message. So I installed the Oracle.DataAccess (version 2.102.4.0) DLL in GAC using GACUtil. I think it also looks the version which is specified in the dbproviders.xml. (If I'm wrong please feel free to comment here)

That's for the Spring framework. However in order to work NHibernate you should have Oracle.DataAccess DLL in you BIN folder(Else it throws "The provider is not compatible with the version of oracle client" error) and related oracle instant client in the same location (else it throws "Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format." error).

You don't have to install oracle client in the machine if you use oracle instant client (Pretty sure everybody knows it). In my bin folder I put the Oracle.DataAccess (version 4.112.2.0) and instant client DLLs (as mentioned in the question). I used version 4.112.2.0 because I couldn't find instant client DLLs for the version 2.102.4.0. (I know it's a mess, but that's how it works)

So now everything works fine.

Small tip: if anyone wants to use GacUtil in the remote server and don't want to install .net framework SDK, Copy the gacutil.exe and gacutil.exe.config file to the remote server and run it form there. Make sure to use version="v2.0.50727". If you use version="v4.0.30319" then it will add the DLL to C:\Windows\Microsoft.NET\assembly instead of C:\Windows\assembly.

answered on Stack Overflow May 22, 2013 by Hello World
1

Make sure you are compiling on a 64 bit processor. A lot of environments default to 32 bit and will not recognize the 64 bit dll.

answered on Stack Overflow Jan 16, 2015 by Steve • edited Jan 16, 2015 by Magnilex
0

Oracle windows clients are the worst. You have my sympathies.

You are on the right track with checking the GAC. In particular pay close attention to any Oracle.DataAccess.Policy entries. These allow Oracle to assume backwards compatibility between versions. When installing multiple versions of the Oracle client on the same machine the Oracle installer may make some incorrect assumptions about which version should be used. If possible I recommend only having 1 version of Oracle installed or at least only 1 version configured in the GAC.

Check this thread for help with debugging the problem: https://forums.oracle.com/forums/thread.jspa?threadID=415012

answered on Stack Overflow May 14, 2013 by CharlesC
0

I had a similar issue and the fix was adding an assembly binding redirect to the web.config for the version included in the project. I noticed that this was required because I enabled fusionlog on the server (How to enable assembly bind failure logging (Fusion) in .NET)

Btw, Microsoft don't recommend using GacUtil for production servers.

answered on Stack Overflow Jul 9, 2019 by stevie_c

User contributions licensed under CC BY-SA 3.0