C
C#2y ago
?

The type name 'ServiceController' could not be found in the namespace 'System.ServiceProcess'.

As it says, I have using System.ServiceProcess but still I'm not able to create a ServiceController variable
5 Replies
?
?2y ago
Using .NET 6 and also tried .NET Core 3.1 I need that to connect to other computer and check in which state services there are
Anton
Anton2y ago
show us the project file
?
?2y ago
This?
Anton
Anton2y ago
the csproj file
?
?2y ago
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

</Project>
Okay, I just fixed that by running a CMD command dotnet add package System.ServiceProcess.ServiceController --version 6.0.0 lol Thank you for your help @AntonC anyway!