使用ODP.NET 64位的.NET Web服务

时间:2011-10-21 07:44:56

标签: web-services odp.net

我在.net4.0中创建了一个Web服务。它通过ODP.NET4连接到oracle数据库。仅供参考我使用ODAC112021Xcopy_X64并安装了odp4和asp4。该服务在开发环境中运行良好。

但是在将它发布到在同一台机器上运行的IIS后,我得到以下异常:

System.ServiceModel.FaultException`1 was unhandled
  Message=Could not load file or assembly 'Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]

我使用64位odp.net,我在Windows Server 2008 R2 64bit上运行并在Visual Studio中切换到64位。

有人可以告诉我我错过了什么或做错了吗?

我还尝试将ORACLE.DATACCESS.dll复制到bin文件夹。

提前致谢

2 个答案:

答案 0 :(得分:0)

这是一个黑暗的镜头,因为我无法重新创建问题,但在IIS中运行时,您需要确保您使用的特定框架(此处为4.0)的信任级别可以访问相应的dll和文件

你可以卸载/重新安装odp位,或者 直接调用'oracle permission'软件 %ORA_HOME \产品\ 11.2.0 \的Client_1 \ odp.net \ BIN \ 4 \ OraProvCfg.exe

另外,查看自述文件(特别是本部分): %ORA_HOME \产品\ 11.2.0 \ Client_1与\ odp.net \ DOC \ readme.txt文件 (这是我认为您可能感兴趣的模糊)

==============================
ORACLEPERMISSION RELATED NOTES
==============================

1. Configuring OraclePermission for Web Applications in high or medium trust

For Web Applications operating under high or medium trust, OraclePermission 
needs to be configured in the appropriate "web_<trust level>.config"  file so 
that the application does not encounter any security errors.  This 
configuration can be done through the OracProvCfg tool. OraProvCfg.exe will
make the appropriate entries in both web_hightrust.config as well as 
web_mediumtrust.config associated with the specified .NET framework version. 

Given below is an example on the usage of OraProvCfg tool for configuring 
OraclePermission in a .NET 2.0 web application:

    OraProvCfg.exe /action:config  /product:odp /component:oraclepermission 
                   /frameworkversion:v4.0.30319
                   /providerpath:<Oracle.DataAccess.dll full path>

On running the above command, The following entry will be made in  
"web_hightrust.config" and  "web_mediumtrust.config" under ASP.NET permissionset

<IPermission class="Oracle.DataAccess.Client.OraclePermission, Oracle.DataAccess, Version=4.112.2.50, Culture=neutral, PublicKeyToken=89b483f429c47342" version="1" Unrestricted="true" />

OraProvCfg can also be used to remove these entries from these config files 
when they need to be removed.

    OraProvCfg.exe /action:unconfig  /product:odp  /component:oraclepermission
                   /frameworkversion:v4.0.30319
                   /providerpath:<Oracle.DataAccess.dll full path>


2. Configuring OraclePermission For Windows Applications in partial trust

For Windows applications operating in a partial trust environment, the 
OraclePermission entry should be specified under the appropriate permission 
set in security.config file. (Security.config is available in 
%windir%\Microsoft.NET\Framework\{version}\CONFIG). The example below 
specifies the OraclePermission entry that would be required for a .NET 2.0 
Windows application

<IPermission class="Oracle.DataAccess.Client.OraclePermission, Oracle.DataAccess, Version=4.112.2.50, Culture=neutral, PublicKeyToken=89b483f429c47342" version="1" Unrestricted="true" />

专门检查这些配置文件(“ web_hightrust.config ”和“ web_mediumtrust.config ”)搜索类似的条目

<IPermission class="Oracle.DataAccess.Client.OraclePermission,
Oracle.DataAccess, Version=4.112.2.50, Culture=neutral,
PublicKeyToken=89b483f429c47342" version="1" Unrestricted="true" />

(本自述文件来自EF的beta 3,所以我希望版本号不同)

您还可以查看此论坛(看起来与此思路相似) https://forums.oracle.com/forums/thread.jspa?threadID=575320

HTH

答案 1 :(得分:0)

检查编译器计算机(32/64位)中的ODAC目标平台是否与放置Web服务的生产服务器相同。