为什么ODP.NET 11 xcopy部署在安装了Oracle DB 10的计算机上不起作用? [英] Why doesn't ODP.NET 11 xcopy deployment work on a machine with Oracle DB 10 installed?

查看:75
本文介绍了为什么ODP.NET 11 xcopy部署在安装了Oracle DB 10的计算机上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,该应用程序在.exe文件所在的目录下使用ODAC 11的本地版本.其想法是,我们希望我们的应用程序使用本地ODAC 11,而不管用户在她身上安装了什么软件.机器.

I have an app that uses a local version of ODAC 11 below the directory that the .exe file is in. The idea is that we want our app to use the local ODAC 11 regardless of what else the user has installed on her machine.

Oracle.DataAccess.dll与.exe在同一目录中.

Oracle.DataAccess.dll is in the same directory as the .exe.

当客户端计算机上未安装Oracle客户端时,它运行良好,但是在安装了Oracle Database 10.2.0.something的计算机上启动它时出现错误:

It works fine when the client machine has no Oracle client installed, but I get an error when starting it on a machine with Oracle Database 10.2.0.something installed:

The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.

[Stack Trace]

The provider is not compatible with the version of Oracle client
OracleException
   at Oracle.DataAccess.Client.OracleInit.Initialize()
   at Oracle.DataAccess.Client.OracleConnection..cctor()

我猜想这与运行时绑定策略有关,但是在Google上搜索"Oracle/ODAC/ODP.NET运行时绑定策略"并没有发现任何有用的信息.

I'm guessing that this has something to do with the runtime binding policy, but a search for "Oracle/ODAC/ODP.NET runtime binding policy" on Google has not turned up anything useful.

有人知道如何解决该问题吗?

Does anyone know how to resolve the issue?

如果不是这个特定问题,有人可以向我介绍如何做我想做的事情的概述:确保我的应用程序无论如何都使用ODAC 11?

If not this specific issue, can someone point me towards an overview of how to do what I want to do: make sure that my application uses the ODAC 11 no matter what?

推荐答案

据我所知,问题是,尽管Oracle.DataAccess.dll与应用程序位于同一目录中,但找不到其较低级别homies(oci等),因此存在兼容性错误.

So as I understand it, the issue was that while Oracle.DataAccess.dll was in the same directory as the app, it could not find its lower-level homies (oci, et al), hence the compatibility error.

事实证明,如果您希望应用程序与ODAC 11 xcopy部署一起使用,而不考虑用户在计算机上可能安装了什么,那么您需要做两件事:

Turns out that if you want an application to work with ODAC 11 xcopy deployment regardless of what else the user may have installed on her machine, you need to do 2 things:

  1. 设置进程的PATH环境变量. (我已经在这样做了.)
  2. 设置进程的ORACLE_HOME环境变量. (我没有这样做.)

  1. Set the PATH environment variable for the process. (I was already doing this.)
  2. Set the ORACLE_HOME environment variable for the process. (I was not doing this.)

Environment.SetEnvironmentVariable("PATH", Environment.CurrentDirectory + "\\oracle\\11.1\\odac;" + Environment.CurrentDirectory + "\\oracle\\11.1\\odac\\bin;", EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("ORACLE_HOME", Environment.CurrentDirectory + "\\oracle\\11.1\\odac", EnvironmentVariableTarget.Process);

同样重要的是要注意,Oracle不仅会因为环境问题,而且如果目标计算机上缺少一个文件,也会引发此错误.尽管设置了环境,但在其他计算机上也遇到了相同的错误,因为我将Subversion设置为忽略名为"bin"的目录,因此未将OraOps DLL复制到客户端.

It's also important to note that Oracle will throw this error not just for environmental issues, but also if one of the files is missing on the target machine. I got this same error on other machines despite the Environment settings because I had Subversion set to ignore directories called "bin", so the OraOps DLL was not being copied to the client.

这篇关于为什么ODP.NET 11 xcopy部署在安装了Oracle DB 10的计算机上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆