Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SqlClient error after updating Windows - "The incoming tabular data stream (TDS) remote procedure call > (RPC) protocol stream is incorrect"

Since updating Windows 10 to 1803, I have begun receiving this error anytime I run an EF query that joins against a table-valued function that takes in a scalar parameter.

Message: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 2 (""): Data type 0x00 is unknown.

Stack Trace: at System.Data.SqlClient.SqlCommand.<>c.b__180_0(Task1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.d__c.MoveNext()

I am using Entity Framework v6.2 in .NET 4.6 framework projects. I verified that the same code executes without a problem on another computer using Windows 10 1709. I updated the computer to Windows 10 1803 with no other change, and I started getting the error above. Code causing the error:

var query = from fs in db.ViewWithInformation
            join e in db.GetEventsForPerson(personnelId) on fs.Event_Id equals e.Event_Id
            where !fs.Is_Deleted
            select fs;
return await query.ToArrayAsync();

If I remove the join against db.GetEventsForPerson, the query runs. The SQL generated by the EF query above runs fine in SSMS.

Edit 5/15/2018: I have confirmed that this is specifically caused by .NET Framework 4.7.2. I manaully installed .NET 4.7.2 on my Windows 10 1709 computer, and the error started up again.

like image 457
Zach Green Avatar asked May 14 '18 23:05

Zach Green


4 Answers

My name is Peter Carlin and I work in the SQL Server team. I first want to apologize for this incident and the impact on users of .NET Framework 4.7.2. I next want to explain what happened and how Microsoft is fixing it in more detail.

The issues is due to improvements to the Always Encrypted functionality in SQL. These improvements expand the set of operations that can be done in Always Encrypted, however they are not yet ready for applications to use. These improvements involve changes to both SqlClient and SQL server side. We introduced an error in .NET Framework 4.7.2 such that in some circumstances (related to MARS) SqlClient incorrectly thinks the added functionality is in use and sends invalid requests to SQL. SQL rejects those with the error messages seen in this thread. This only happens if connected to a SQL server that has support for the added functionality as well. SQL DB is the first to get the latest SQL changes, and recently deployed the added functionality.

Our immediate fix is to ensure the SQL DB acts as if it does not have the added functionality, so the SqlClient side bug in 4.7.2 is not encountered. This is why we are able to fix the issue with a SQL DB side change.

We are working as quickly as wise/safe to deploy, validate, the fix. At this point the fix is deployed to approximately 10% of our production capacity, with expected completion by Monday May 21st.

like image 111
Peter Carlin Avatar answered Oct 29 '22 22:10

Peter Carlin


We are investigating this as a possible regression on SqlClient on .NET Framework. Anyone that can provide a repro project, pelase post it at https://github.com/Microsoft/dotnet/issues/749.

like image 22
divega Avatar answered Oct 29 '22 22:10

divega


Temp Workaround: Per ChainbridgeTech change MultipleActiveResultSets from TRUE to FALSE in my connection string, and the error stops.

This has been reported and is being worked on. They still need a repro and I'm still working on isolating shareable data that I can make public:

https://github.com/Microsoft/dotnet/issues/749

Duplicate issue of TDS Error on Azure Entity Framework SQL Calls after Windows 10 April 2018 Update

like image 2
RyanCEI Avatar answered Oct 29 '22 21:10

RyanCEI


Microsoft is actively looking at this issue. Based on what we know so far, the issue is related to .NET framework 4.7.2 with MARS (Multiple Active Result Sets) when using async/await.

Known workarounds include rolling back the Windows/.NET framework update, not using MARS or not using async/await.

If you have additional information that can help us to narrow it down, please add to the issue report at https://github.com/Microsoft/dotnet/issues/749

like image 1
Tomas Talius Avatar answered Oct 29 '22 21:10

Tomas Talius