为什么 ODP.NET 11 xcopy 部署在安装了 Oracle DB 10 的机器上不起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/491876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why doesn't ODP.NET 11 xcopy deployment work on a machine with Oracle DB 10 installed?
提问by Josh Kodroff
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.
我有一个应用程序在 .exe 文件所在的目录下使用本地版本的 ODAC 11。这个想法是我们希望我们的应用程序使用本地 ODAC 11,而不管用户在她的机器上安装了什么。
Oracle.DataAccess.dll is in the same directory as the .exe.
Oracle.DataAccess.dll 与 .exe 位于同一目录中。
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:
当客户端机器没有安装 Oracle 客户端时它工作正常,但在安装了 Oracle 数据库 10.2.0.something 的机器上启动它时出现错误:
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()
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.
我猜这与运行时绑定策略有关,但是在 Google 上搜索“Oracle/ODAC/ODP.NET 运行时绑定策略”并没有发现任何有用的信息。
Does anyone know how to resolve the issue?
有谁知道如何解决这个问题?
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?
如果不是这个特定问题,有人可以指出我如何做我想做的事情的概述:确保我的应用程序无论如何都使用 ODAC 11?
采纳答案by Josh Kodroff
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.
因此,据我所知,问题在于,虽然 Oracle.DataAccess.dll 与应用程序位于同一目录中,但它无法找到其较低级别的伙伴(oci 等),因此出现兼容性错误。
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:
事实证明,如果您希望应用程序与 ODAC 11 xcopy 部署一起使用,而不管用户在她的机器上安装了什么,您需要做两件事:
- Set the PATH environment variable for the process. (I was already doing this.)
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);
- 为进程设置 PATH 环境变量。(我已经在这样做了。)
为进程设置 ORACLE_HOME 环境变量。(我不是在做这个。)
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);
EDIT: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.
编辑:同样重要的是要注意,Oracle 不仅会因为环境问题,还会在目标机器上缺少其中一个文件时抛出此错误。尽管有环境设置,但我在其他机器上遇到了同样的错误,因为我将 Subversion 设置为忽略名为“bin”的目录,因此 OraOps DLL 没有被复制到客户端。
回答by AnthonyVO
An article titled "Deploying ODP.NET with Oracle Instant Client" found at http://alderprogs.blogspot.com/2009/04/deploying-odpnet-with-oracle-instant.htmlgave what was for me about the best explanation of how to deliver a stripped down xcopy type deployment with your application. Only 5 Oracle DLLs required for support.
在http://alderprogs.blogspot.com/2009/04/deploying-odpnet-with-oracle-instant.html 上找到的一篇题为“使用 Oracle Instant Client 部署 ODP.NET”的文章给出了对我来说最好的解释如何为您的应用程序提供精简的 xcopy 类型部署。支持只需要 5 个 Oracle DLL。
That said the answers by ObiWanKenobi and Josh Kodroff provides important additional info which matches with my experience.
也就是说,ObiWanKenobi 和 Josh Kodroff 的回答提供了与我的经验相符的重要附加信息。
Add to that: http://www.brothersincode.com/post/Oracle-ODPnet-xcopy-deployment-for-aspnet.aspx
添加到:http: //www.brothersincode.com/post/Oracle-ODPnet-xcopy-deployment-for-aspnet.aspx
回答by ObiWanKenobi
You want to force your ODP.NET drivers to use the copy of oci.dll that is in your local folder, instead of the one already installed.
您希望强制 ODP.NET 驱动程序使用本地文件夹中的 oci.dll 副本,而不是已安装的副本。
You can force this by either
您可以通过以下任一方式强制执行此操作
- setting the PATH variable so the system finds your copy of of oci.dll first (as in the answer by Josh Kodroff)
- 设置 PATH 变量,以便系统首先找到您的 oci.dll 副本(如 Josh Kodroff 的回答)
or
或者
- you can use ODP.NET configuration section in app.config (or web.config) to explicitly set the value of "DllPath".
- 您可以使用 app.config(或 web.config)中的 ODP.NET 配置部分来显式设置“DllPath”的值。
For details, see http://ora-00001.blogspot.com/2010/01/odpnet-minimal-non-intrusive-install.htmland http://database.in2p3.fr/doc/oracle/Oracle_Database_11_Release_1_(11.1)_Documentation/win.111/e10927/featConfig.htm
有关详细信息,请参阅http://ora-00001.blogspot.com/2010/01/odpnet-minimal-non-intrusive-install.html和http://database.in2p3.fr/doc/oracle/Oracle_Database_11_Release_1_(11.1) _Documentation/win.111/e10927/featConfig.htm
回答by DCookie
If you're using oracle client 10.2.0.1 or 10.2.0.2, Oracle Note 215255.1 indicates that if you apply patchset 10.2.0.3 it fixes the issue. Get the 10.2.0.3 database patch (852MB) and patch the client home. Yes, it's the full database server patchset, but it applies to the client as well.
如果您使用的是 oracle 客户端 10.2.0.1 或 10.2.0.2,Oracle Note 215255.1 指出如果您应用补丁集 10.2.0.3,它会修复该问题。获取 10.2.0.3 数据库补丁(852MB)并修补客户端主页。是的,它是完整的数据库服务器补丁集,但它也适用于客户端。