Anand Emmanuel
Anand Emmanuel

Reputation: 21

How to remap app.config for assembly Oracle.DataAccess from Version '2.112.2.0' to '2.112.3.0'

I am new to C#.

I wrote a C# console application which uses ODP to connect with Oracle database using Oracle.DataAccess.Client namespace. My dev machine is using Oracle.DataAccess ver 2.112.2.0 and the dev server is also using Oracle.DataAccess ver 2.112.2.0 and the program works fine. The prod server using a higher version of Oracle.DataAccess ver 2.112.3.0 and the program does not run and I get the following exception.

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89b483f
429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342'
   at OPSegmentTDs.Programu.Main(String[] args)


I tried installing ODAC for Oracle client 11.2.0.3.0 on my dev machine and added the higher ver of Oracle.DataAccess reference 2.112.3.0 in my application and when I built it I got this warning but the program built successfully.

Consider app.config remapping of assembly "Oracle.DataAccess, Culture=neutral, PublicKeyToken=89b483f429c47342" from Version "2.112.2.0" [] to Version "2.112.3.0" [C:\Oracle\OraODP1123\product\11.2.0\client_2\ODP.NET\bin\2.x\Oracle.DataAccess.dll] to solve conflict and get rid of warning.
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3247: Found conflicts between different versions of the same dependent assembly.
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /platform:AnyCPU /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:C:\Work\Build\GOLD\GIS2002\GISLib\bin\Debug\GIS.dll /reference:C:\Work\Build\09072012\Linde.Niche.DB\bin\Debug\Linde.Niche.DB.dll /reference:C:\Work\Build\09072012\Linde.Niche.DB.OP\bin\Debug\Linde.Niche.DB.OP.dll /reference:C:\Work\Build\09072012\Linde.Niche\bin\Debug\Linde.Niche.dll /reference:C:\Work\Build\09072012\OPLib\OPLib\bin\Debug\OPLib.dll /reference:C:\Oracle\OraODP1123\product\11.2.0\client_2\ODP.NET\bin\2.x\Oracle.DataAccess.dll /reference:"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\OPSegmentTDs.exe /target:exe Program.cs Properties\AssemblyInfo.cs

When I tried running the new build on my prod server the application is crashing with the same error

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89b483f
429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342'
   at OPSegmentTDs.Programu.Main(String[] args)

Upvotes: 2

Views: 6929

Answers (1)

Danny Varod
Danny Varod

Reputation: 18068

Try copying the correct version of Oracle's DLLs (from ODAC112030Xcopy_32bit.zip or ODAC112030Xcopy_x64.zip) under your application's bin/setup folder and add the following to your application's app.config:

<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>

Upvotes: 1

Related Questions