0

I have already raised this with Microsoft Support, but somehow this takes forever, so I thought I throw this in here and see if anyone has already encountered (and maybe solved?) this: I have a C# application that uses both Microsoft.SqlSer.SqlManagementObjects (currently 161.47027.0) and Microsoft.Data.SqlClient (currently 5.0.0.0). Since upgrading the SqlClient a while back, my SMO library is broken completely. The exception I keep getting is:

System.MissingMethodException: Method not found: 'Void Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Encrypt(Boolean)'.     
at Microsoft.SqlServer.Management.Common.ConnectionSettings.GetConnectionString()     
at Microsoft.SqlServer.Management.Common.ConnectionSettings.get_ConnectionString()     
at Microsoft.SqlServer.Management.Common.ConnectionManager.InitSqlConnectionObject(Boolean setConnectionString, Boolean removeIntegratedSecurity)     
at Microsoft.SqlServer.Management.Common.ServerConnection..ctor()     
at Microsoft.SqlServer.Management.Smo.ExecutionManager..ctor(String name)     
at Microsoft.SqlServer.Management.Smo.Server..ctor(String name)     
at DBHelper.GeneralDBHelper.GetServerSettings(MSSQLParameter param)     

The code in question looks like this:

Server Srv;
Srv = new Server(param.DeviceName);

Where param.DeviceName is a string holding the server name.

Does anyone have a useful idea?

thx

6
  • welcome to stackoverflow hannes! may we know if this a net-core or .net? it may affect the answer to your question. also, have you tried to use newer SqlManagementObjects? - see this QA. best of luck! Commented Oct 13, 2022 at 8:55
  • You have to use the Microsoft.Data.SqlClient version that Microsoft.SqlSer.SqlManagementObjects references. Commented Oct 13, 2022 at 8:57
  • @BagusTesa Sorry, I should have mentioned that: I am targeting .Net Framework 4.8 Alberto I can't use the version referenced directly (3.0.0.0), I need the Data.SqlClient for other things too, and I need the 5.0 version for those parts of the software. Besided, The package clearly states "SqlClient >=3.0.0.0" Commented Oct 13, 2022 at 9:37
  • Taken from here. The Encrypt property seems to have changed from a boolean to an enum with v5 for the SqlClient and the version of SMO you use still expect is to be a boolean. Commented Oct 13, 2022 at 10:01
  • 1
    There are preview nuget packages for SMO available that may be compatible SqlClient 5. Its mentioned atleast in the change log raw.githubusercontent.com/Microsoft/sqlmanagementobjects/main/… Commented Oct 13, 2022 at 10:04

0

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.