Microsoft.SqlServer.Management.Smo --> SmoApplication.EnumAvailableSqlServers(false) throws error

phani Sastry 1 Reputation point
2022-03-24T11:14:26.26+00:00

Hi.

have developing an App in .net 6.0 framework for which need to enumerate sql server instances available in the network domain. When calling below code

added nuget packages Microsoft.SqlServer.Management objects

System.Data.SqlClient,

Microsoft.Windows.Compatibility

Microsoft.SqlServer.Management.Smo --> SmoApplication.EnumAvailableSqlServers(false) throws following error

could not instantiate object Microsoft.SqlServer.Management.Smo.AvailableSQLServers.

at Microsoft.SqlServer.Management.Sdk.Sfc.ObjectCache.CreateObjectInstance(Assembly assembly, String objectType)

at Microsoft.SqlServer.Management.Sdk.Sfc.ObjectCache.CreateObjectInstance(String assemblyName, String objectType)

at Microsoft.SqlServer.Management.Sdk.Sfc.ObjectCache.LoadElement(ObjectLoadInfo oli)

at Microsoft.SqlServer.Management.Sdk.Sfc.ObjectCache.LoadFirstElementVersionless(Urn urn, Object ci)

at Microsoft.SqlServer.Management.Sdk.Sfc.Environment.GetServerVersion(Urn urn, Object ci)

at Microsoft.SqlServer.Management.Sdk.Sfc.Environment.GetObjectInfo(Object ci, RequestObjectInfo req)

at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.GetObjectInfo(Object connectionInfo, RequestObjectInfo requestObjectInfo)

at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.FixPropertyList(Object connectionInfo, Urn urn, String[] fields, RequestFieldsTypes requestFieldsType)

at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.GetData(Object connectionInfo, Request request)

at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.Process(Object connectionInfo, Request request)

Same code works fine in framework 4.8.

Can some one give pointers?

Regards,

Phani.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,265 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,489 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Ronen Ariely 15,081 Reputation points
    2022-03-25T08:14:37.79+00:00

    hi,

    could not instantiate object Microsoft.SqlServer.Management.Smo.AvailableSQLServers.

    Please check if the following discussion solve your issue:

    https://github.com/microsoft/sqltoolsservice/issues/890


  2. phani Sastry 1 Reputation point
    2022-03-25T09:20:08.85+00:00

    we need to populate all the servers in network domain, this doesnt seem to work for me.

    0 comments No comments

  3. Roberto.cr.tv 1 Reputation point
    2022-05-18T07:26:45.477+00:00

    Hi! Have you solved this problem?

    0 comments No comments

  4. phani Sastry 1 Reputation point
    2022-05-18T07:36:30.767+00:00

    No. the problem is not solved

    0 comments No comments