Closed SeanFeldman closed 5 years ago
For those who find this issue - this is an issue with System.Data.SqlClient. TransactionScopes are not supported by System.Data.SqlClient versions earlier than 4.5.0.
In my case, used a 3rd party library (Dapper) that referenced earlier version of System.Data.SqlClient. Ironically, Dapper latest version (current for today) is on the older version of System.Data.SqlClient as well 🙂
Closing this issue.
Scenario
Performing transactional message processing with a database transaction. To avoid ASB client from throwing exceptions, an internal database transaction is wrapped with transaction scope using
TransactionScopeOption.Suppress option
. This excludes database transaction from participating in the ambient ASB transaction. This works with .NET Framework, but doesn't work with .NET Core.An exception is thrown - System.NotSupportedException: 'Enlisting in Ambient transactions is not supported.'.
Stacktrace
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.OpenAsync(CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at ReproApp.Program.ExecuteInnerTransaction(String sqlConnectionString) in C:\Users\Sean\Desktop\SuppressScopeRepro\ReproApp\Program.cs:line 72 at ReproApp.Program.Main(String[] args) in C:\Users\Sean\Desktop\SuppressScopeRepro\ReproApp\Program.cs:line 53 at ReproApp.Program.In other reported occasions 'Local transactions are not supported with other resource managers/DTC.' is reported to be thrown.
Repro project: https://github.com/SeanFeldman/SuppressScopeRepro/
SuppressScopeRepro.sln
on .NET Framework - doesn't failSuppressScopeRepro.sln
on .NET Core - failsVersions