【问题标题】:Transactionscope .net core 2Transactionscope .net 核心 2
【发布时间】:2018-03-13 01:09:12
【问题描述】:

我收到这个错误

不支持加入环境事务

在我的带有 VS 2017 15.3.2 (System.Data.SqlClient v4.4.0) 的 win 10 PC 上的 .net core 2 控制台应用程序中调试以下代码时

using (TransactionScope scope = new TransactionScope())
{
  using (SqlConnection connection1 = new SqlConnection(_configuration["ConnectionString"]))
  {
    connection1.Open();
  }
  scope.Complete();
}

Transactionscope 是 .net 标准 2 的一部分,上面的代码取自微软的文档 https://docs.microsoft.com/en-gb/dotnet/api/system.transactions.transactionscope?view=netcore-2.0

【问题讨论】:

    标签: transactionscope .net-core-2.0


    【解决方案1】:

    我认为这已作为 GitHub 上的问题报告给 Microsoft

    https://github.com/dotnet/corefx/issues/24282

    【讨论】:

      【解决方案2】:

      安装System.Data.SqlClient >= 4.8.2 应该可以解决这个问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-04-07
        • 2017-10-23
        • 2016-06-11
        • 2018-06-30
        • 2019-10-20
        • 1970-01-01
        相关资源
        最近更新 更多