[英]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();
}
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.