简体   繁体   English

Oracle.ManagedDataAccess.Core - 事务范围问题

[英]Oracle.ManagedDataAccess.Core - Transaction Scope Issue

I'm trying to convert a project to .Net Core but I have hit a stumbling block.我正在尝试将项目转换为 .Net Core,但我遇到了绊脚石。

When I open two different oracle connections within a transaction scope, the below error is received:当我在一个事务范围内打开两个不同的 oracle 连接时,收到以下错误:

"Operation is not supported on this platform."

"   at OracleInternal.MTS.MTSRMManager.CCPEnlistDistributedTxnToSysTxn(OracleConnectionImpl connImpl, Transaction txn, MTSTxnRM txnRM, MTSTxnBranch txnBranch)

   at OracleInternal.MTS.MTSRMManager.CCPEnlistTransaction(OracleConnectionImpl connImpl, Transaction transaction, MTSTxnRM txnRM, MTSTxnBranch txnBranch)

   at OracleInternal.ConnectionPool.PoolManager`3.GetEnlisted(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria)

   at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)

   at Oracle.ManagedDataAccess.Client.OracleConnection.Open()"

The code below causes this error when opening the second connection.打开第二个连接时,下面的代码会导致此错误。 In addition, this does not happen on the standard framework Oracle.ManagedDataAccess.此外,这不会发生在标准框架 Oracle.ManagedDataAccess 上。 It only happens on the Oracle.ManagedDataAccess.Core version.它只发生在 Oracle.ManagedDataAccess.Core 版本上。

My guess is that it looks to be something with connection pooling, but I could use some help.我的猜测是它看起来与连接池有关,但我可以使用一些帮助。

If you use the same connection string for each connection there is no problem.如果对每个连接使用相同的连接字符串,则没有问题。 Only occurs when you have two different connections.仅当您有两个不同的连接时才会发生。

    using (TransactionScope scope = new TransactionScope())
    {
        using (var conn = new OracleConnection(connectionString1))
        {
              conn.Open();
        }

        using (var conn = new OracleConnection(connectionString2))
        {
             conn.Open(); //Exception occurs here
        }

       scope.Complete();
    }

As per the docs :根据文档

ODP.NET Core does not support Distributed Transactions. ODP.NET Core 不支持分布式事务。

Hence why "Operation is not supported on this platform."这就是为什么“此平台不支持操作”的原因。

If you use the same connection string for each connection there is no problem.如果对每个连接使用相同的连接字符串,则没有问题。 Only occurs when you have two different connections.仅当您有两个不同的连接时才会发生。

If you use only a single connection then you will be fine, since you aren't using a Distributed Transaction.如果您只使用一个连接,那么您会没事的,因为您没有使用分布式事务。 Once you have more than one though, a Distributed Transaction will be involved (which ODP.NET Core does not support).但是,一旦有多个,就会涉及分布式事务(ODP.NET Core 不支持)。 This is consistent with what you are seeing.这与您所看到的一致。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用.net core和Oracle.ManagedDataAccess.Core从Oracle查询中获取ID - Getting IDs back from an Oracle query using .net core and Oracle.ManagedDataAccess.Core Oracle.ManagedDataAccess.Core 3.21.61 使用 UDT Oracle 11g 和 c# .net 6 - Oracle.ManagedDataAccess.Core 3.21.61 using UDT Oracle 11g with c# .net 6 Oracle.ManagedDataAccess.Core 和 ORA-01017:用户名/密码无效; 登录被拒绝 - Oracle.ManagedDataAccess.Core and ORA-01017: invalid username/password; logon denied 交易范围问题 - Transaction Scope Issue 使用插入的Oracle.ManagedDataAccess.EntityFramework事务获取插入记录的ID时出现问题 - Problem in getting inserted record`s ID Using transaction with Oracle.ManagedDataAccess.EntityFramework Oracle .Net Core托管驱动程序:Oracle.ManagedDataAccess.Types.TimeStamp..cctor()异常 - Oracle .Net Core Managed Driver : Oracle.ManagedDataAccess.Types.TimeStamp..cctor() exception 使用 EF 6.4 + Oracle.ManagedDataAccess.EntityFramerowk 和 .net core 3.1 应用程序重用旧版 .net 4.7.2 库? - Reuse legacy .net 4.7.2 libs with EF 6.4 + Oracle.ManagedDataAccess.EntityFramerowk with a .net core 3.1 app? 使用ASP.NET的Oracle中的交易范围 - Transaction Scope in Oracle with ASP.NET Oracle驱动程序:Framework 3.5和Oracle.ManagedDataAccess - Oracle Driver: Framework 3.5 and Oracle.ManagedDataAccess 如何使用Oracle.ManagedDataAccess连接到Oracle - How to connect to oracle using Oracle.ManagedDataAccess
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM