oracle OCIEnvCreate 失败,返回代码 -1,但错误消息文本不适用于 ODP.net

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12901045/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 04:33:36  来源:igfitidea点击:

OCIEnvCreate failed with return code -1 but error message text was not available with ODP.net

oracleodp.net

提问by Nate

I'm trying to study ORP.net and looking over this article on Deploying ODP.NET with Oracle Instant Client. I have downloaded and copied all DLLs in project as the article explains, however on the testing step, when the app is built I get the following error:

我正在尝试研究 ORP.net 并查看有关使用 Oracle Instant Client 部署 ODP.NET 的这篇文章。如文章所述,我已经下载并复制了项目中的所有 DLL,但是在测试步骤中,构建应用程序时出现以下错误:

OCIEnvCreate failed with return code -1 but error message text was not available

I am using oraclexeand I have an Oracle client. I have given full permission for authenticated users. How can I solve this problem?

我正在使用oraclexe并且我有一个 Oracle 客户端。我已经为经过身份验证的用户提供了完全许可。我怎么解决这个问题?

回答by Santiago

When trying to connect to an Oracle database you receive the following error:

尝试连接到 Oracle 数据库时,您收到以下错误:

OCIEnvCreate failed with return code -1 but error message text was not available

OCIEnvCreate 失败并返回代码 -1 但错误消息文本不可用

The causes:

原因:

  1. You are using an unsupported version of the Oracle Client (older than 11.2) on Windows 7.

  2. DLLs from a previous installation of Oracle Client have been left on the system, causing a conflict.

  1. 您在 Windows 7 上使用不受支持的 Oracle 客户端版本(早于 11.2)。

  2. 来自先前安装的 Oracle Client 的 DLL 已留在系统上,从而导致冲突。

The solutions:

解决方法:

  1. Install a supported version of the Oracle Client.

  2. Perform a search for "OCI.DLL" on the local machine. If you find any instances of this file in any location other than your ORACLE_HOMErename or delete it. If in doubt, uninstall the Oracle Client, then perform the search again. Anything that is leftover is the culprit.

  1. 安装受支持的 Oracle 客户端版本。

  2. 在本地机器上搜索“OCI.DLL”。如果您在ORACLE_HOME重命名或删除它以外的任何位置找到此文件的任何实例。如果有疑问,请卸载 Oracle Client,然后再次执行搜索。任何剩余的东西都是罪魁祸首。

回答by MichaelS

What worked for me was setting ORACLE_HOMEto oracle\client\your_version\home1instead of oracle\client\your_version\home1\BIN

什么工作对我来说是设置ORACLE_HOMEoracle\client\your_version\home1代替oracle\client\your_version\home1\BIN

回答by B2K

I also had to make symbolic directory links for x86 and x64 applications. The steps I had to take were as follows:

我还必须为 x86 和 x64 应用程序创建符号目录链接。我必须采取的步骤如下:

  1. Make sure NET MANAGER could connect to Oracle.
  2. mklink /D C:\Windows\System32\orcl
  3. mklink /D C:\Windows\SysWoW64\orcl
  4. set environment variable for ORACLE_HOME to C:\windows\system32\orcl
  5. add C:\windows\system32\orcl\bin to your PATH
  6. It didn't work until after I restarted my computer
  1. 确保 NET MANAGER 可以连接到 Oracle。
  2. mklink /DC:\Windows\System32\orcl
  3. mklink /DC:\Windows\SysWoW64\orcl
  4. 将 ORACLE_HOME 的环境变量设置为 C:\windows\system32\orcl
  5. 将 C:\windows\system32\orcl\bin 添加到您的 PATH
  6. 直到我重新启动计算机后才起作用

回答by Charlie

I also had the same issue when trying to connect Power BI to a Oracle database.

尝试将 Power BI 连接到 Oracle 数据库时,我也遇到了同样的问题。

I had 2 versions of the Oracle client installed. 11.2 and 10.2. When I uninstalled the older version, it worked like a charm.

我安装了 2 个版本的 Oracle 客户端。11.2 和 10.2。当我卸载旧版本时,它就像一个魅力。

One thing to note is that in Power BI, when connecting to the oracle database it asked me to provide the server. But what is expects me to enter is the name of that connection in my tnsnames.ora file :)

需要注意的一件事是,在 Power BI 中,当连接到 oracle 数据库时,它要求我提供服务器。但是期望我输入的是我的 tnsnames.ora 文件中该连接的名称:)

回答by God Inez

Reinstalling Oracle and updating the ORACLE_HOMEenvironment variable with the new installation folder worked for me. Don't forget to recycle your application pool before trying your application again.

重新安装 Oracle 并ORACLE_HOME使用新的安装文件夹更新环境变量对我有用。在再次尝试您的应用程序之前,不要忘记回收您的应用程序池。