Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why my C# does not have System.ServiceProcess Library?

Tags:

This is the code. I just wanna test the library of System.ServiceProcess library.

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);         }     } } 

However, when I run the C# code, its says:

Error 1 The type or namespace name 'ServiceProcess' does not exist in the namespace 'System' (are you missing an assembly reference?)

What went wrong?

like image 525
user1535147 Avatar asked Nov 04 '13 07:11

user1535147


People also ask

Why is my Windows C drive so full?

Windows to save the deleted files in the Recycle Bin for a period (30 days or even longer by default). If you never cleared the recycle bin, it will take up a certain space on your system C drive, which as a result, your C drive is getting full. So we suggest you empty the recycle bin regularly.

What do I do when my C drive is full?

Right-click on C: drive and select Properties, and then click "Disk Cleanup" button in the disk properties window. Step 2. In Disk Cleanup window, select the files you want to delete and click OK. If this does not free up much space, you can click Clean up system files button to delete system files.

Why my local disk C is red?

If the C: drive is showing as red that means it doesn't have much free space left, see below to increase space. The following procedure cleans up files associated with your user account. You can also use Disk Cleanup to clean up all the files on your computer. 1.

Why is my C drive full and D drive empty?

If you're using a Windows machine, the most common issue is when the C drive is full and the D drive is empty. Unreasonable partition size allocation and installing too many programs can be the reasons your C drive is full, and the D drive is empty.


1 Answers

The System.ServiceProcess namespace belongs to System.ServiceProcess.dll and it isn't added as a reference by default.

For this, in the solution window, right click on "References" and choose "Add Reference..". Go to the .NET tab, and double click on System.ServiceProcess.dll.

enter image description here

This assembly is probably in the folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727.

like image 154
Soner Gönül Avatar answered Oct 08 '22 06:10

Soner Gönül