Design time error with System.Data.SqlClient

Gilbert Seong 40 Reputation points
2023-04-06T20:21:41.65+00:00

We are using Visual Studio 2022 version 17.5.3 Our C# WINFORM projects use System.Data.SqlClient library to manipulate data but
All forms' design view have following error and not opened properly after update visual studio Unable to cast object of type 'System.Data.SqlClient.SqlCommand' to type 'Microsoft.Data.SqlClient.SqlCommand'. But project can be complied and worked without any issue though. Also, I attached screenshot of empty winform project. (C# winform .net 4.6.1) I added components SqlConnection, SqlCommand, SqlDataAdapter from SqlClient.Data.SqlClient to toolbox. Error message pops up when I add any of them to design view of form. But these errors are not occurred with Visual Studio 2019. Untitled-3.jpg

Developer technologies Visual Studio Other
{count} votes

Accepted answer
  1. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2023-04-07T05:42:56.1066667+00:00

    Hi @Gilbert Seong

    Welcome to Microsoft Q&A! 

    I could reproduce your issue on my side and found the same feedback from other community users:

    VS IDE: Unable to cast object of type 'System.Data.SqlClient.SqlCommand' to type 'Microsoft.Data.SqlClient.SqlCommand'. - Developer Community (visualstudio.com) 

    Windows Forms designer since VS 17.5: "Unable to cast object of type 'System.Data.SqlClient.SqlCommand' to type 'Microsoft.Data.SqlClient.SqlCommand'. - Developer Community (visualstudio.com) 

    It seems be a known issue. You can also vote it and add your comment there to track the process.

    If there are any updates, I will sync here. 

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.