Đây là mã. Tôi chỉ muốn kiểm tra thư viện của thư viện System.ServiceProcess.Tại sao C# của tôi không có Thư viện 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);
}
}
}
Tuy nhiên, khi tôi chạy mã C#, nó nói:
Lỗi 1 Loại hoặc namespace tên 'ServiceProcess' không tồn tại trong không gian tên 'hệ thống' (là bạn thiếu một tham khảo lắp ráp?)
Điều gì đã xảy ra?
'Bạn thiếu một tài liệu tham khảo lắp ráp? 'Lỗi này đang hướng dẫn bạn về phía giải pháp rồi. Tra cứu ['ServiceController'] (http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller (v = vs.110) .aspx) và bạn sẽ thấy điều này: 'Assembly: System .ServiceProcess (trong System.ServiceProcess.dll) ' –