Windows Forms designer error since VS 17.5 update

cstauffer 20 Reputation points

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

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.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,863 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,764 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Karsten Laufer 0 Reputation points

    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