You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading to .NET 5 and consequently updating Microsoft.Data.SqlClient, we started to see strange errors related to the package. The call stack is very poor and I am not sure how to reproduce it.
Exception message:System.AggregateException
A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (Object reference not set to an instance of an object.)
Stack trace: System.NullReferenceException: Object reference not set to an instance of an object.
?, in void SNIPacket.ReadFromStreamAsync(Stream stream, SNIAsyncCallback callback)
?, in uint SNITCPHandle.ReceiveAsync(ref SNIPacket packet)
?, in uint SNIMarsConnection.ReceiveAsync(ref SNIPacket packet)
?, in void SNIMarsConnection.HandleReceiveComplete(SNIPacket packet, uint sniErrorCode)
?, in void Task.ExecuteWithThreadLocal(ref Task currentTaskSlot, Thread threadPoolThread)
Further technical details
Microsoft.Data.SqlClient version: 2.0.20168.4
.NET target: .NET 5.0.5
SQL Server version: SQL Server 2019
Operating system: Docker, Linux 5.4.17-2011.5.3.el8uek.x86_64 #2 SMP Wed Jul 29 22:09:11 PDT 2020
Hi @kewinbrand. If the application setup allows, can you try your application with MARS set to false and also as @ErikEJ mentioned try to update to the latest version please?
If the issue persist can you provide a sample repro app as well?
Activity
ErikEJ commentedon Jul 14, 2021
Have you tried version 3?
JRahnama commentedon Jul 14, 2021
Hi @kewinbrand. If the application setup allows, can you try your application with
MARSset tofalseand also as @ErikEJ mentioned try to update to the latest version please?If the issue persist can you provide a sample repro app as well?
kewinbrand commentedon Jul 16, 2021
I closed the issue unintentionally.
Will update the packages and report in a few days. Just to show how sporadic the error is

cheenamalhotra commentedon Jul 16, 2021
Hi @kewinbrand
The driver version you're using is a non-LTS and is Out of Support. Also this issue had been fixed in v2.1 (ref #692).
Please upgrade to either v2.1 or v3.0.
If you continue to reproduce error, please provide a repro.
kewinbrand commentedon Jul 16, 2021
I don't reference the package manually. I see that Microsoft.EntityFrameworkCore.SqlServer uses [email protected]. Should I raise a issue to them?

ErikEJ commentedon Jul 16, 2021
Just add an explicit packagereference to the newer version
https://erikej.github.io/efcore/sqlclient/2020/03/22/update_mds.html
ErikEJ commentedon Jul 16, 2021
Sadly EF Core 5 still depends on 2.0.1.
cheenamalhotra commentedon Jul 20, 2021
@kewinbrand do you have any further questions?
I'm hoping referencing to a newer version resolved your issue?
kewinbrand commentedon Jul 26, 2021
@cheenamalhotra the problem has gone away after referencing the package
i still don't believe ef core was released with such problem...
ErikEJ commentedon Jul 27, 2021
@kewinbrand far from all customers use the managed SNI layer, it is only applicable to non- Windows platforms