更改 Oracle 客户端注册表中的 NLS_LANG 设置的影响

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

Effects of changing NLS_LANG setting in the registry for Oracle Client

oracleregistryodp.netoracleclientora-12705

提问by LauraB

We are in the process of moving from the .NET Microsoft oracle driver to the ODP.NET driver.

我们正在从 .NET Microsoft oracle 驱动程序迁移到 ODP.NET 驱动程序。

One of the problems we have had is this error:

我们遇到的问题之一是这个错误:

ORA-12705: Cannot access NLS data files or invalid environment specified

ORA-12705: 无法访问 NLS 数据文件或指定的环境无效

We were able to stop the error by modifying the registry and changing the setting (see this question)

我们能够通过修改注册表和更改设置来停止错误(请参阅此问题

In our case we changed

在我们的例子中,我们改变了

HKEY_LOCAL_MACHINE - SOFTWARE - ORACLE - NLS_LANG

HKEY_LOCAL_MACHINE - SOFTWARE - ORACLE - NLS_LANG

which was set to NA

设置为 NA

to be the same as

HKEY_LOCAL_MACHINE - SOFTWARE - ORACLE - HOME0 - NLS_LANG

HKEY_LOCAL_MACHINE - SOFTWARE - ORACLE - HOME0 - NLS_LANG

which was set correctly

哪个设置正确

My question is why would there be different NLS_LANG settings in the registry, and might there be any knock on effects of changing this value?

我的问题是为什么注册表中会有不同的 NLS_LANG 设置,更改此值是否会产生任何影响?



Update: I've just found in the Oracle NLS FAQthe following

更新:我刚刚在Oracle NLS 常见问题解答中找到以下内容

For Oracle version 7:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE

For Oracle Database versions 8, 8i and 9i:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOMEx\

where "x" is the unique number identifying the Oracle home.

HOME0 is the first installation

For Oracle Database 10g:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_<oracle_home_name>

There you have an entry with name NLS_LANG

对于 Oracle 版本 7:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE

对于 Oracle 数据库版本 8、8i 和 9i:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOMEx\

其中“x”是标识 Oracle 主目录的唯一编号。

HOME0是第一次安装

对于 Oracle 数据库 10g:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_<oracle_home_name>

在那里你有一个名字的条目 NLS_LANG

OK, so there are different registry settings for different versions...

好的,所以不同版本有不同的注册表设置...

Note:

Some people are confused by finding a NLS_LANG set to "NA" in HKEY_LOCAL_MACHINE\SOFTWARE\ORACLEwhen no version 7 was installed. This is used for backwards compatibility, and can be ignored.

笔记:

有些人HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE在未安装版本 7 时发现 NLS_LANG 设置为“NA”而感到困惑 。这用于向后兼容,可以忽略。

I have Oracle 9i, so now I'm even more confused - why is the ODP.NET dll looking at the Oracle 7 registry setting?

我有 Oracle 9i,所以现在我更加困惑 - 为什么 ODP.NET dll 会查看 Oracle 7 注册表设置?

回答by Chris Taylor

PER Oracle Notes on the 11g ODP release, the following can cause this error:

根据 11g ODP 版本的 Oracle 注释,以下情况可能导致此错误:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\NLS_LANG=NA <--- This NA does in fact cause this error if set to NA.

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\NLS_LANG=NA <--- This NA does in fact cause this error if set to NA.

You can try DELETINGthe key if not needed or setting it to a valid NLS_LANGsetting for your locale.

DELETING如果不需要,您可以尝试使用该密钥,或者将其NLS_LANG设置为适合您的语言环境的有效设置。

For us we set it to AMERICAN_AMERICA.WE8MSWIN1252.

对于我们,我们将其设置为AMERICAN_AMERICA.WE8MSWIN1252.

回答by Nick Giles

I had a similar problem with the;

我有一个类似的问题;

ORA-12705: Cannot access NLS data files or invalid environment specified

ORA-12705: 无法访问 NLS 数据文件或指定的环境无效

The ODP.NET dll's or instant client were reading the registry;

ODP.NET dll 或即时客户端正在读取注册表;

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\NLS_LANG=NA

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\NLS_LANG=NA

The value NA caused the error.

值 NA 导致错误。

This was because I already had a client installation but I wanted to use the oracle instant client via network drive for the a VB.NET app with ODP.NET.

这是因为我已经安装了客户端,但我想通过网络驱动器将 oracle 即时客户端用于带有 ODP.NET 的 VB.NET 应用程序。

My simple fix in my vb.net solution was for example to adjust the environment for the application via:

我在 vb.net 解决方案中的简单修复是例如通过以下方式调整应用程序的环境:

Environment.SetEnvironmentVariable("NLS_LANG", 
                    "AMERICAN_AMERICA.WE8MSWIN1252", 
                    EnvironmentVariableTarget.Process)

nb. The Oracle "NLS FAQ" link is no longer valid (2012)

备注 Oracle“NLS FAQ”链接不再有效(2012)

回答by wardies

In our case we did not want to make any potentially breaking changes to the Oracle registry because we were installing our web service on a production Oracle 9i server.

在我们的例子中,我们不想对 Oracle 注册表进行任何潜在的破坏性更改,因为我们是在生产 Oracle 9i 服务器上安装我们的 Web 服务。

The solution was simply to prevent ODAC from being able to see any ORACLE registry keys by denying all access to that key for the user ID our web service was running as.

解决方案只是通过拒绝对运行 Web 服务的用户 ID 的键的所有访问来防止 ODAC 能够看到任何 ORACLE 注册表键。

  1. Start -> Run... regedit(as an administrator)
  2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
  3. Right click on the ORACLEkey -> Permissions...
  4. Click the Add... button.
  5. Add the web service user name configured in your web service's application pool identity (e.g. IUSR_MyWebService); this is the user name that appears against your w3wp.exe process in Task Manager.
  6. Press OK.
  7. For the new user permissions, check "Deny" against the Full Control permission and press OK.
  1. 开始 -> 运行... regedit(以管理员身份)
  2. 导航 HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
  3. 右键单击ORACLE密钥 -> 权限...
  4. 单击添加...按钮。
  5. 添加在您的 Web 服务的应用程序池标识中配置的 Web 服务用户名(例如IUSR_MyWebService);这是出现在任务管理器中 w3wp.exe 进程的用户名。
  6. 按确定。
  7. 对于新用户权限,请针对完全控制权限选中“拒绝”,然后按确定。

This worked just fine and as a bonus we have ensured that our application is isolated from any future changes to the ORACLEregistry keys.

这工作得很好,作为奖励,我们确保我们的应用程序与任何未来对ORACLE注册表项的更改隔离。

Tip:you can prove to yourself that the user in question has no access to the keys in question by closing any running instances of the Registry Editor, start a CMDprompt as that user(using Run As...) and then launching regeditfrom the command prompt.

提示:您可以通过关闭注册表编辑器的任何正在运行的实例,以该用户的身份启动CMD提示(使用运行身份...),然后regedit从命令启动,从而向自己证明有问题的用户无权访问有问题的键迅速的。

回答by Andreas

the Oracle Client (ORACLE_HOME\bin\ora*.dll) is looking for a file named "oracle.key" in the same directory. This file contains the name of the registry key which belongs to this Oracle client installation. (e.g. "Software\ORACLE\HOME3") hth Andreas

Oracle 客户端 (ORACLE_HOME\bin\ora*.dll) 正在同一目录中查找名为“oracle.key”的文件。此文件包含属于此 Oracle 客户端安装的注册表项的名称。(例如“Software\ORACLE\HOME3”)hth Andreas

回答by LauraB

This was all resolved in the end by installing the ODAC 11 client components (downloaded from the Oracle website). I think the system was getting confused because we had copied the ODAC dlls across rather than fully installing the client. ODP.NET is expecting an Oracle 11 client and didn't know where to find the Oracle Home.

最后通过安装 ODAC 11 客户端组件(从Oracle 网站下载)解决了所有问题。我认为系统变得混乱,因为我们复制了 ODAC dll 而不是完全安装客户端。ODP.NET 期待 Oracle 11 客户端,但不知道在哪里可以找到 Oracle Home。

NB if you are installing the ODAC components using xCopy deployment then do notinstall them to an existing Oracle Home directory (eg c:\oracle\ora92 for 9i client). This causes a 'Provider is not compatible with the version of Oracle Client' error.

NB如果您正在安装使用Xcopy部署则ODAC组件不要将它们安装到现有的Oracle主目录(如C:对于9i客户机\ ORACLE \ ora92)。这会导致“提供程序与 Oracle 客户端版本不兼容”错误。