sql-serverazure-sql-databasesqlclient.net-4.7.2

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.


Solution

  • 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.