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.
I have the same issue, have submitted a bug report:
@cstauffer, I also reproduced the problem. I also recommend that you could ask the Question in DC or follow other's submitted question.
In my case, it appears that the old VS toolbox items for SqlCommand, SqlDataAdapter, etc. no longer appear to compile properly as part of the VS designer rendering code. I had to take them out of the .designer files and move the initialization code into the _Load event for the form. Once I did that, the designer would render the form again without errors.
Initially, the issue showed up as an error that it wouldn't render because it couldn't load Microsoft.Data.SqlClient version 126.96.36.199 (a DLL that I didn't use in my .NET 4.8 code, since that's something for .NET Core 3.0 or later), in case anyone is having that problem too.
Sign in to comment