1

I'm connection to an Microsoft SQL Server 2008 in C# .NET 4.0 Application. Now I want to display all sql Services from the remote computer.

ManagedComputer managedComputer = new ManagedComputer("ServerName", "Login", "Password");
foreach (var service in managedComputer.Services)
{
    Console.WriteLine(service.Name + " | " + service.ServiceState);
}

The problem is, that I can't build the solution because Visual Studio 2012 brings the error, I should add an Assembly. Here is the error message:

The type 'Microsoft.SqlServer.Management.Smo.Wmi.ServiceState' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.SqlServer.WmiEnum, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'.

Of course I added this assembly but still there is no change.

The problem comes from the Code service.ServiceState.

How can I fix this problem? Is this Assembly only for .NET 2.0?
Or is there any other way to get the status (running, stopped...) of an remote sql service?

4

0 回答 0