Windows Forms designer error since VS 17.5 update

cstauffer 25 Reputation points
2023-03-07T14:31:36.37+00:00

Since updating to 17.5.0 (as well as 17.5.1) I am unable to open winforms design files due to the following error:

Unable to cast object of type 'System.Data.SqlClient.SqlCommand' to type
'Microsoft.Data.SqlClient.SqlCommand'.

This only happens for forms using components from the System.Data.SqlClient namespace, such as SqlDataAdapter, SqlCommand, SqlConnection, etc. There really isn't any additional info provided in Visual Studio aside from that error message. The projects all target .NET Framework 4.8.

Nothing has changed with the code, and applications still compile and run as they did prior to the update. I'm not sure where to look to see what is causing this issue. The projects do not have a reference to Microsoft.Data.SqlClient in them so I'm not sure why it's trying to cast stuff to types in that assembly.

Developer technologies | Windows Forms
Developer technologies | Visual Studio | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Karsten Laufer 0 Reputation points
    2023-03-08T08:19:54.21+00:00

    Even a fresh new project "Windows Forms" has the same problem.

    When drag/drop a data component form the Toolbox like SqlCommand, SqlDataAdapter the message appears:

    Failed to create component "SqlCommand"... System.InvalidCastException: Unable to cast object of type 'System.Data.SqlClient.SqlCommand' to type 'Microsoft.Data.SqlClient.Sqlcommand'

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.