I have created a console application using the .Net 8 environment and there is this code in Program.cs:
TransactionManager.ImplicitDistributedTransactions = true;
var transactionOptions = new TransactionOptions();
transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
transactionOptions.Timeout = TimeSpan.FromSeconds(3600);
using (IDbConnection connection1 = new SqlConnection(infocitiConnectionString))
using (IDbConnection connection2 = new SqlConnection(storageConnectionString))
{
TransactionScope ts = null;
try
{
ts = new TransactionScope(TransactionScopeOption.Required, transactionOptions);
{
connection1.Open();
//connection1.Execute(sql: sqlDelete);
connection1.Close();
connection2.Open();
//connection2.Execute(sql: sqlInsert);
connection2.Close();
ts.Complete();
}
}
finally
{
ts?.Dispose();
}
}
Unfortunately, I get a deadlock on the code line:
ts?.Dispose();
I searched the internet and the net 8 source code but found nothing clear
If I comment out the ts.Complete(); code, the deadlock disappears.

I updated the Microsoft.Data.SqlClient package from version 2.1.5 to last actual version(5.1.2) and the deadlock went away