C# Error -‘ServiceController’ could not be found in the namespace

This blog post will show you how to fix the following .NET C# build error when trying to work with Windows Services.

Full Error

You receive the following error message when trying to build a .NET C# project that uses the ServiceProcess Namespace.

Severity Code Description Project File Line Suppression State Error CS1069 The type name 'ServiceController' could not be found in the namespace 'System.ServiceProcess'.  
This type has been forwarded to assembly 'System.ServiceProcess.ServiceController


The build process fails because the .NET package ServiceController is not installed. To fix the error, open a terminal window in the project directory and run the following command.

dotnet add package System.ServiceProcess.ServiceController –version 7.0.1

Alternatively, you can add the following package to your package file.

<PackageReference Include="System.ServiceProcess.ServiceController" Version="7.0.1" />

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.