2012-11-08 50 views
2

我是C#的新手。如何重新映射程序集Oracle.DataAccess从版本'2.112.2.0'到'2.112.3.0'的app.config

我写了一个C#控制台应用程序,它使用ODP使用Oracle.DataAccess.Client命名空间与Oracle数据库连接。我的开发机器使用Oracle.DataAccess版本2.112.2.0,开发服务器也使用Oracle.DataAccess版本2.112.2.0,并且程序工作正常。 prod服务器使用更高版本的Oracle.DataAccess ver 2.112.3.0,并且该程序不运行,并且出现以下异常。

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 

当我想我的督促服务器上运行的新构建的应用程序与相同的错误

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) 

回答

1

尝试复制甲骨文的DLL文件的正确版本(从ODAC112030Xcopy_32bit.zip或ODAC112030Xcopy_x64.zip崩溃)下的应用程序的bin/setup文件夹中,并将以下内容添加到应用程序的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> 
相关问题