The Go function seems to work after adjusting the code to use the Microsoft.Data.SqlClient package instead of deprecated System.Data.SqlClient. Probably some things were improved and fixed.
The other functions seem to work too.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I'm experiencing thread deadlock issues when using the TransactionScope class in a .NET 8 project. The deadlock occurs on the TransactionScope.Dispose method. Strangely enough, this seems to be an issue only in .NET 8, but not in .NET Framework 4.8.
I have created a sample Visual Studio solution to illustrate this, which I added as attachment to this post. However, this website does not allow for zip files to be added, so I renamed to a TXT file. You'll have to rename to ZIP again in order to unzip it.
In this sample, a distributed transaction is needed to move some data from database A to database B (which requires DTC - it might even happen from server to server in the real world). The solution consists of:
Both console apps have a dependency to the 'Procedures' project, to ensure that the same code is called in both cases. The only external NuGet dependency is System.Data.SqlClient, version 4.9.0. At the time of writing, this is the latest version.
Procedure for testing:
At random position, the .NET 8 version of the console app will hang. Sometimes immediately at the first cycle, sometimes after a couple of dozens of cycles. Notice that the .NET Framework 4.8 version of the console app doesn't experience such problems.
Even when running the fully synchronous sample (option 'S') in .NET 8 -which doesn't involve any threading at all- the deadlock issue occurs.
I have no idea what I'm doing wrong, so I hope someone can shed some light on this. Also, why any .Dispose method -from any class- would cause a deadlock is beyond me. I thought these methods were supposed to be safe to call at all times.
Kind regards,
Stefan Adriaenssen
The Go function seems to work after adjusting the code to use the Microsoft.Data.SqlClient package instead of deprecated System.Data.SqlClient. Probably some things were improved and fixed.
The other functions seem to work too.
your link returns gibberish, and without sample code it hard to comment. but it appears you are getting deadlock trying to call async thread sync. the is a common issue:
https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html
https://medium.com/rubrikkgroup/understanding-async-avoiding-deadlocks-e41f8f2c6f5d