這是代碼。我只想測試System.ServiceProcess庫的庫。爲什麼我的C#沒有System.ServiceProcess庫?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceProcess;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("hi");
var srv = new ServiceController("MyService");
Console.WriteLine("MyService Status {0}", srv.Status);
if (srv.Status != ServiceControllerStatus.Running)
srv.Start();
System.Threading.Thread.Sleep(1000000);
}
}
}
然而,當我運行的C#代碼,它說:
錯誤1類型或命名空間名稱ServiceProcess「不 命名空間「系統」存在(是缺少程序組裝參考?)
出了什麼問題?
'你缺少程序集引用? 「錯誤已經引導你走向解決方案。查找['ServiceController'](http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller(v = vs.110).aspx),你會看到:'Assembly:System .ServiceProcess(在System.ServiceProcess.dll中)' –