JPRO
JPRO

Reputation: 1062

Deploying Oracle Instant Client alongside existing Oracle installations

I have developed a new application that uses Entity Framework to access an Oracle database. This is working as expected locally, using the latest version of ODP.NET. I am now trying to deploy this application on a production server running many other legacy applications. Ideally I would like my new application to make use of its own ODP.NET / Oracle dlls and not have to change the existing Oracle install on the prod server.

I followed this guide:

http://jeremybranham.wordpress.com/2011/04/25/oracle-instant-client-with-odp-net/

Which seems to have had some success based on the comments.

However, I get the following exception when attempting to create the entities object:

Outer Exception

Exception has been thrown by the target of an invocation.

Inner Exception

The type initializer for 'Oracle.DataAccess.Client.OracleClientFactory' threw an exception.
at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized)
at System.Reflection.RtFieldInfo.InternalGetValue(Object obj, Boolean doVisibilityCheck, Boolean doCheckConsistency)
at System.Reflection.RtFieldInfo.GetValue(Object obj)
at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
at MyAppMVC.Models.DataModels.STSProcedureEntities..ctor()
at MyAppMVC.Services.MyService.GetPersons(String lastName)

Upvotes: 1

Views: 2685

Answers (2)

hugo
hugo

Reputation: 51

Although you appear to have resolved your problem by installing an additional client you could possible have added the following config in you app / web.config file.

  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.DataAccess.Client" />
      <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET"
           type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, 
           PublicKeyToken=89b483f429c47342"/>
    </DbProviderFactories>
  </system.data>

And dropped the binaries in your local bin folder.

Upvotes: 2

JPRO
JPRO

Reputation: 1062

Answering my own question here. We ultimately installed a second version of Oracle, using the default settings which put the new version into a client_2 folder.

  • D:\oracle\product\11.2.0\client (old version)
  • D:\oracle\product\11.2.0\client_2 (new version)

The only additional install step was dropping in the previous TNSNAMES.ORA file into the new client_2. This file is located in client\network\admin using the file path above.

Because all of our applications were set to specifically seek out their correct Oracle versions (SpecificVersion=true) everything mostly worked without modification. For those that did not we had to drop in the older version of Oracle.DataAccess.dll (from client, not client_2) into that application's bin folder.

Upvotes: 1

Related Questions