Visitar URL original
Missing Type Microsoft.Data.SqlClient.SqlAuthenticationMethod - .NET Framework 4.8 · Issue #4064 · dotnet/SqlClient · GitHub
Skip to content

Missing Type Microsoft.Data.SqlClient.SqlAuthenticationMethod - .NET Framework 4.8 #4064

Closed
1 of 1 issue completed

Description

@rozeboosje

Describe the bug

Code snippet in VB.NET

`'

Dim sConnectionString As String

sConnectionString = "Server=[server name here].database.windows.net;Database=[database name here];Application Name=[something];uid=[a QL username];pwd=[a SQL password];TrustServerCertificate=True;"

Dim oCONSQL As Microsoft.Data.SqlClient.SqlConnection = Nothing  

oCONSQL = New Microsoft.Data.SqlClient.SqlConnection(sConnectionString)  

oCONSQL.Open()  

If oCONSQL.State = ConnectionState.Open Then  

    Dim oCONServerConnection As Microsoft.SqlServer.Management.Common.ServerConnection = Nothing  

    oCONServerConnection = New Microsoft.SqlServer.Management.Common.ServerConnection(sqlConnection:=oCONSQL)

End If`
Exception message: Could not load type 'Microsoft.Data.SqlClient.SqlAuthenticationMethod' from assembly 'Microsoft.Data.SqlClient, Version=7.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'.
Stack trace:

To reproduce

The above may suffice to reproduce the issue?

Expected behavior

A clear and concise description of what you expected to happen.

Further technical details

Microsoft.Data.SqlClient version: 7.0.0
.NET target: (e.g. .NET Framework 4.8)
SQL Server version: (e.g. SQL Server 2022 - Azure SQL)
Operating system: n/a

Additional context

Activity

  1. rozeboosje commented on Mar 18, 2026

    @rozeboosje
    Author

    I created a standalone project for .NET Framework 4.8 and installed nuget package Microsoft.Data.SqlClient 7.0.0 and I pasted in the above code. It then complained about the last two statements and I realised I also needed to add the nuget package for Microsoft.Sql.SqlManagementObjects - the latest version of that is 181.15.0 and once I did that it threw the exact same error. So it looks to me that SqlManagementObjects is not up to date on Microsoft.Data.SqlClient (yet?)

    What should I do with that information?

  2. rozeboosje commented on Mar 18, 2026

    @rozeboosje
    Author

    I cannot find a github page where I could alert its developers to this problem?

  3. rozeboosje commented on Mar 18, 2026

    @rozeboosje
    Author
  4. rozeboosje commented on Mar 18, 2026

    @rozeboosje
    Author

    Please note: We're using SMO because our software needed to be able to process a large SQL script with statements separated by "GO" commands against Azure SQL databases. We would really prefer not to have to write code to "parse" such scripts into separate statements.

    If there is a way to achieve this without using SMO, please let us know how.

  5. ErikEJ commented on Mar 18, 2026

    @ErikEJ
    Contributor

    Given that 7.0.0 was released yesterday maybe give the ecosystem a little breating room to catch up?

    Did you read the breaking changes docs?

    Do you NEED 7.0.0 today?

  6. rozeboosje commented on Mar 18, 2026

    @rozeboosje
    Author

    Thank you ErikEJ - yes I'm happy to wait for that and you're right, I don't need it today. I am hoping though that in the longer run I can keep all nuget packages up to date

  7. ErikEJ commented on Mar 18, 2026

    @ErikEJ
    Contributor

    Did you add a reference to the new Azure package?

  8. rozeboosje commented on Mar 18, 2026

    @rozeboosje
    Author

    Yes, thanks ErikEJ, but that made no difference. I'm a little unfamiliar with where to find information in these "github" places.... if there's a link to these "breaking changes" you mentioned, could you share it with me here?

  9. cheenamalhotra commented on Mar 18, 2026

    @cheenamalhotra
    Member

    Do you experience any issue without SMO in a standalone VB.NET app?

  10. moved this from To triage to Waiting for customer in SqlClient Boardon Mar 18, 2026
  11. rozeboosje commented on Mar 18, 2026

    @rozeboosje
    Author

    Not using SMO is not an option for us as we need to process large SQL scripts that contain "GO" statements. I want to avoid having to write code to split such scripts into parts as we cannot guarantee that people will always have followed strict rules on how to write them.

    If there is a way to run such scripts directly without having to use SMO, and you can point me at a simple example for this I will be happy to try that out.

  12. shueybubbles commented on Mar 19, 2026

    @shueybubbles

    @cheenamalhotra can you have a version of the old type in the sqlclient dll and use a TypeForwardedTo attribute on SqlAuthenticationMethod type?

  13. moved this from Waiting for customer to In progress in SqlClient Boardon Mar 19, 2026
  14. added this to the 7.0.1 milestone on Mar 20, 2026
  15. moved this from In progress to In review in SqlClient Boardon Mar 20, 2026
  16. fredericDelaporte commented on Mar 24, 2026

    @fredericDelaporte

    After upgrading Microsoft.Data.SqlClient to 7.0.0 in a C# .net10 project using SMO, we encountered the same issue.

    System.TypeLoadException: Could not load type 'Microsoft.Data.SqlClient.SqlAuthenticationMethod' from assembly 'Microsoft.Data.SqlClient, Version=7.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'.
       at Microsoft.SqlServer.Management.Common.ConnectionSettings.InitFromSqlConnection(SqlConnection sc)
       at Microsoft.SqlServer.Management.Common.ConnectionSettings.InitFromSqlConnection(SqlConnection sc)
       at Microsoft.SqlServer.Management.Common.ConnectionManager..ctor(SqlConnection sqlConnectionObject, IRenewableToken accessToken)
       at Microsoft.SqlServer.Management.Common.ServerConnection..ctor(SqlConnection sqlConnection, IRenewableToken accessToken)
       at Microsoft.SqlServer.Management.Common.ServerConnection..ctor(SqlConnection sqlConnection)
    

    Downgrading the SQL Client to 6.1.4 in this project dodges the issue. (But now, we have inconsistent dependencies in our solution.)

  17. moved this from In review to Done in SqlClient Boardon Mar 26, 2026
  18. moved this from Done to In progress in SqlClient Boardon Apr 6, 2026
  19. rozeboosje commented on Apr 27, 2026

    @rozeboosje
    Author

    Happy to confirm that the 7.0.1 release of Microsoft.Data.SqlClient has resolved this.

  20. moved this from In progress to Done in SqlClient Boardon May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

External 🔗Issue is in an external component

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions