3

Microsoft.SqlServer.SqlManagementObjects 161.47027.0

Microsoft.Data.SqlClient 5.0.0

After upgrading Microsoft.Data.SqlClient from 4.1.0 to 5.0.0 I got this error creating a ServerConnection object:

using Microsoft.SqlServer.Management.Common;

var serverConnection = new ServerConnection("localhost", "sa", "mypwd");

System.MissingMethodException: 'Method not found: 'Void Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Encrypt(Boolean)

It looks for a not implemented set_Encrypt method inside a Microsoft.Data.SqlClient.SqlConnectionStringBuilder

Does it mean Microsoft.SqlServer.SqlManagementObjects has not been updated yet to support Microsoft.Data.SqlClient 5.0.0?

If so do I need to wait for this update before I can upgrade Microsoft.Data.SqlClient 5.0.0 into my project?

2
  • Have you seen this? Commented Aug 23, 2022 at 11:40
  • You should be using a username and password. Instead use credentials by using a connection string with property "Trusted_Connection=Yes". See connectionstrings.com/sql-server Commented Aug 23, 2022 at 12:57

3 Answers 3

3

You can also upgrade the ServerManagementObjects reference to 170.7.0-preview to resolve. Apparently the issue is with the smo library not the sqlclient library. https://github.com/dotnet/SqlClient/issues/1702

Their code should be backwards compatible, but they need to be recompiled against MDS 5.0

Sign up to request clarification or add additional context in comments.

Comments

1

Below is MyConnectionString"

"Server=tcp:xxx.xxxx.windows.net;Authentication=Active Directory Default;Database=TestDB;TrustServerCertificate=True;MultipleActiveResultSets=True;"

Had the error:

Method not found: 'Void Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Encrypt(Boolean)'. When usingMicrosoft.Data.SqlClient 5.0.1.`

Fixed By: Downgraded the package Microsoft.Data.SqlClient to 4.1.0.and Using Microsoft.SqlServer.SqlManagementObjects 161.47021.0.

Fixed the error. Thank you for this post.

Comments

0

We had the same MissingMethodException when attempting the update of Microsoft.Data.SqlClient 4.1.0 to 5.0.0 in our system. Simply updating Microsoft.Data.SqlClient - independently of Microsoft.SqlServer.SqlManagementObjects - resulted in the exception when constructing the Microsoft.SqlServer.Management.Common.ServerConnection using SQL Server Authentication (not Windows Authentication).

This snippet causes the MissingMethodException if using Microsoft.Data.SqlClient 5.0.0 (worked in 4.1.0):

      Return New ServerConnection With {
        .ApplicationName = My.Application.Info.Title,
        .ServerInstance = connectionParameters.DataSource,
        .ConnectTimeout = connectionParameters.ConnectionTimeout,
        .LoginSecure = False,
        .Login = connectionParameters.UserName,
        .Password = connectionParameters.Password
      }

For now, we are holding off on updating Microsoft.Data.SqlClient, but went ahead with the Microsoft.SqlServer.SqlManagementObjects update (161.47021.0 to 161.47027.0). I am hopeful that an upcoming Microsoft.Data.SqlClient version will fix this issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.