C# ODP.NET Oracle.ManagedDataAccess 导致 ORA-12537 网络会话文件结束
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29847444/
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
ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file
提问by Greg
Overview
概述
I want to replace Oracle.DataAccess with Orcale.ManagedDataAccess, but opening a connection with the latter throws an ORA-12537 network session end of fileexception.
我想用 Orcale 替换 Oracle.DataAccess。托管DataAccess,但打开与后者的连接会引发ORA-12537 网络会话文件结束异常。
Exception message / stack trace
异常消息/堆栈跟踪
{OracleInternal.Network.NetworkException (0x000030F9): ORA-12537: Netzwerksession: Dateiende at OracleInternal.Network.ReaderStream.Read(OraBuf OB) at OracleInternal.TTC.OraBufReader.GetDataFromNetwork() at OracleInternal.TTC.OraBufReader.Read(Boolean bIgnoreData) at OracleInternal.TTC.MarshallingEngine.UnmarshalUB1(Boolean bIgnoreData) at OracleInternal.TTC.TTCProtocolNegotiation.ReadResponse()}
{OracleInternal.Network.NetworkException (0x000030F9): ORA-12537: Netzwerksession: Dateiende at OracleInternal.Network.ReaderStream.Read(OraBuf OB) at OracleInternal.TTC.OraBufReader.GetDataFromNetwork() at OracleInternal.TTC.OraBufReader.reData() ) 在 OracleInternal.TTC.MarshallingEngine.UnmarshalUB1(Boolean bIgnoreData) 在 OracleInternal.TTC.TTCProtocolNegotiation.ReadResponse()}
I am trying to connect to a Oracle 11g database and do not have a client installed on my local machine.
我正在尝试连接到 Oracle 11g 数据库,但我的本地计算机上没有安装客户端。
Working test application (unmanaged)
工作测试应用程序(非托管)
Using Oracle.DataAccess works fine.
使用 Oracle.DataAccess工作正常。
using System;
using Oracle.DataAccess.Client;
namespace App.Odp.Unmanaged
{
internal class Program
{
private static void Main(string[] args)
{
//dummy connection string. using SID
string connectionString = "User Id=***;password=***;Data Source=1.2.3.4:1521/sid01;";
try
{
using (var conn = new OracleConnection(connectionString))
{
conn.Open();
using (OracleCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "select * from all_users";
using (OracleDataReader reader = cmd.ExecuteReader())
{
Console.WriteLine("VisibleFieldCount: {0}", reader.VisibleFieldCount);
Console.WriteLine("HiddenFieldCount: {0}", reader.HiddenFieldCount);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error:{0}", ex.Message);
}
Console.ReadLine();
}
}
}
References and dependencies
引用和依赖
- Oracle.DataAccess (2.111.7.0)
- oci.dll (11.1.0.1)
- orannzsbb11.dll (11.1.0.6)
- oraociei11.dll (Oracle Call Interface Instant Client)
- OraOps11w.dll (2.111.7.0)
- Oracle.DataAccess (2.111.7.0)
- oci.dll (11.1.0.1)
- orannzsbb11.dll (11.1.0.6)
- oraociei11.dll(Oracle 调用接口即时客户端)
- OraOps11w.dll (2.111.7.0)
Project settings
项目设置
Plattform target x86
Target Framework 4.5
平台目标x86
目标框架 4.5
Failing test application (managed)
失败的测试应用程序(托管)
Using the nuget package Official Oracle ODP.NET, Managed Driver 12.1.21
使用 nuget 包官方 Oracle ODP.NET,Managed Driver 12.1.21
Code is identical to above. Only change:
代码与上面相同。只改变:
using System;
using Oracle.ManagedDataAccess.Client;
//... rest the same as above
References and dependencies
引用和依赖
Only:
仅有的:
- Oracle.ManagedDataAccess (4.121.2.0)
- Oracle.ManagedDataAccess (4.121.2.0)
Project settings
项目设置
Plattform target Any CPU
Target Framework 4.5
平台目标任何 CPU
目标框架 4.5
App.config
应用配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client" />
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<publisherPolicy apply="no" />
<assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
<bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.121.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<!--<dataSource alias="MyDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=1.2.3.4)(PORT=1521))(CONNECT_DATA=(SID=sid01)))" />-->
</dataSources>
<settings>
<!--<setting name="SQLNET.AUTHENTICATION_SERVICES" value="NTS"/>-->
</settings>
</version>
</oracle.manageddataaccess.client>
</configuration>
I have tried different settings (NTS, none, all) and changed the connection string to User Id=XXX;password=XXX;Data Source=MyDataSource;, but the error stays the same.
我尝试了不同的设置(NTS、none、all)并将连接字符串更改为User Id=XXX;password=XXX;Data Source=MyDataSource; ,但错误保持不变。
Questions
问题
- What could be causing the ORA-12537 network session end of fileexception?
- Is a reference / dependency missing?
- Does something have to be configured on the DB server?
- 什么可能导致 ORA-12537 网络会话文件结束异常?
- 是否缺少参考/依赖项?
- 是否必须在数据库服务器上配置某些内容?
UPDATE
更新
On the server we are getting an ORA-12679: Native services disabled by other process but requirederror in the alert.log.
在服务器上,我们收到一个ORA-12679:本地服务被其他进程禁用,但在 alert.log 中需要错误。
It seems to have something to do with the encryption. Commenting out the following lines in the servers sqlnet.ora solves the issue.
这似乎与加密有关。在服务器 sqlnet.ora 中注释掉以下几行可以解决这个问题。
#SQLNET.AUTHENTICATION_SERVICES=(NTS)
#SQLNET.ENCRYPTION_TYPES_SERVER = (rc4_128, rc4_256)
#SQLNET.ENCRYPTION_SERVER=REQUIRED
#ENCRYPTION_WALLET_LOCATION=
# (SOURCE=(METHOD=FILE)(METHOD_DATA=
# (DIRECTORY=...\%ORACLE_SID%\wallet)))
New question
新问题
How do we configure ManagedDataAccess so it works with the encryption?
我们如何配置 ManagedDataAccess 使其与加密一起工作?
Update 2
更新 2
Seems to work now with ODP Managed Driver 12c:
https://www.nuget.org/packages/Oracle.ManagedDataAccess/
现在似乎可以使用 ODP 托管驱动程序 12c:https:
//www.nuget.org/packages/Oracle.ManagedDataAccess/
采纳答案by Christian Shay
Edit: ASO is now supported. Upgrade to ODAC 12c Release 4 or later. If this does not fix your problem, check the alert.log on the database server and investigate (google) any errors that occur there when you attempt to connect.
编辑:现在支持 ASO。升级到 ODAC 12c 第 4 版或更高版本。如果这不能解决您的问题,请检查数据库服务器上的 alert.log 并调查 (google) 在您尝试连接时出现的任何错误。
Original Answer:
原答案:
As of this writing (4/30/15) there is no support for Oracle Advanced Security Option (ASO) encryption with ODP.NET Managed Driver which is what is causing your errors.
在撰写本文时(2015 年 4 月 30 日),不支持使用 ODP.NET 托管驱动程序的 Oracle 高级安全选项 (ASO) 加密,这是导致您出错的原因。
This is very likely to be supported at some point in the future so if you are reading this at a later date, check the latest ODP.NET docs to see if an upgrade of ODP.NET is needed.
这很可能在未来的某个时候得到支持,因此如果您稍后阅读本文,请查看最新的 ODP.NET 文档以查看是否需要升级 ODP.NET。
http://docs.oracle.com/cd/E56485_01/win.121/e55744/InstallConfig.htm#CHDJIDIG
http://docs.oracle.com/cd/E56485_01/win.121/e55744/InstallConfig.htm#CHDJIDIG
回答by David Dindak
As of October 5th, 2015, the Oracle.ManagedDataAccess driver (ODAC 12c Release 4) supports ASO.
自 2015 年 10 月 5 日起,Oracle.ManagedDataAccess 驱动程序(ODAC 12c 第 4 版)支持 ASO。
https://apex.oracle.com/pls/apex/f?p=18357:39:18138408495219::NO::P39_ID:28201
https://apex.oracle.com/pls/apex/f?p=18357:39:18138408495219::NO::P39_ID:28201
回答by Andreas Gunner?s
Make sure that you do not have older versions of Oracle.ManagedDataAccess in the GAC. It seems that several versions of the dll have the same AssemblyVersion.
确保 GAC 中没有旧版本的 Oracle.ManagedDataAccess。似乎有几个版本的 dll 具有相同的 AssemblyVersion。
I had an older version in the CLR 4 GAC (C:\Windows\Microsoft.NET\assembly\GAC_MSIL for me) that got installed with a Oracle 12.1-client.
我在 CLR 4 GAC(对我来说是 C:\Windows\Microsoft.NET\assembly\GAC_MSIL)中有一个旧版本,它安装了 Oracle 12.1 客户端。
Since dll:s in the GAC always are used first the old ASO-uncapable version was used, but I thought that I used the newer version.
由于 dll:s 在 GAC 中始终首先使用,因此使用了旧的 ASO-uncapable 版本,但我认为我使用了较新的版本。
Solution was to uninstall the older version from the GAC. The first installation step in the 12.1.2400 Nuget Package Readme-file is to "Un-GAC and unconfigure any existing assembly".
解决方案是从 GAC 中卸载旧版本。12.1.2400 Nuget 包自述文件中的第一个安装步骤是“取消 GAC 并取消配置任何现有程序集”。
回答by Devang Panchalia
I too struggled with this error. Finally i tried with Oracle.ManagedDataAccess.dll for 12c (Version 4.122.1.0). Created a reference for above dll from the ODAC installed directory (\odp.net\managed\common), it worked...!!! Sharing my solution.
我也为这个错误而挣扎。最后,我尝试使用 Oracle.ManagedDataAccess.dll for 12c(版本 4.122.1.0)。从 ODAC 安装目录 (\odp.net\managed\common) 创建了上述 dll 的引用,它有效......!!!分享我的解决方案。
回答by Carl H?gstedt
Had some of the same problems. Found an entry in the registry: HKEY_LOCAL_MACHINE\SOFTWARE\wow6432\oracle. If this part contains a ODP.NET.managed entry, possible with another key (name version dependend) check if this entyr contains a string called TNS_ADMIN. This string should be deleted or the value changed to a not existing directory. If the string exists and point to a valid directory the Managed Client does not use the setting from the configuration file and fails. Further investigation should be used, but I got my stuff working, and must postpone the rest....
有一些相同的问题。在注册表中找到一个条目:HKEY_LOCAL_MACHINE\SOFTWARE\wow6432\oracle。如果此部分包含 ODP.NET.managed 条目,则可以使用另一个键(名称版本依赖项)检查此条目是否包含名为 TNS_ADMIN 的字符串。应删除此字符串或将值更改为不存在的目录。如果字符串存在并指向有效目录,则受管客户端不使用配置文件中的设置并失败。应该使用进一步的调查,但我的东西已经开始工作了,剩下的必须推迟......
回答by Chris Hammond
I had was getting this error, and it was a simple case that my query that I was running had a mistake.
我遇到了这个错误,这是一个简单的例子,我正在运行的查询有一个错误。

