I am trying to create a simple Windows application using C # to return all local servers on my computer, I use this code for this
var servers = new List<string>(); var serverCollection = new ManagedComputer().ServerInstances.Cast<ServerInstance>().Select(instance => String.IsNullOrEmpty(instance.Name) || instance.Name == defaultMsSqlInstanceName ? instance.Parent.Name : Path.Combine(instance.Parent.Name, instance.Name)) .ToArray(); foreach (var server in serverCollection.Where(server => !servers.Contains(server))) { servers.Add(server); } return servers;
But when I run the application, an unhandled exception of type Microsoft.SqlServer.Management.Smo.SmoException occurred in Microsoft.SqlServer.SqlWmiManagement.dll with the message:
The SQL Server WMI Provider is not available on the local machine.
any help please?
source share