Hi Team, We have Upgraded a windows service from .Net4.7.2 framework to .NetCore 6.0 , We are encountering an issue when we try to start the service through service.msc

Sridhar Reddy Arjula 0 Reputation points
2023-08-14T16:16:29.7333333+00:00

Error Details are as follows:

Application:Myservice.exe

CoreCLR Version: 6.0.2123.36311

.NET Version: 6.0.21

Description: The process was terminated due to an unhandled exception.

Exception Info: System.PlatformNotSupportedException: ServiceController enables manipulating and accessing Windows services and it is not applicable for other operating systems.

   at System.ServiceProcess.ServiceBase..ctor()

   at Myservice..ctor() in C:\Dev\Visual Studio\MyServiceProcessor\Myservice.cs:line 17

   at Myservice.Program.Main() in C:\Dev\Visual Studio\MyServiceProcessor\Myservice\Program.cs:line 22

We have installed System.ServiceProcess.ServiceController from nuget package in order to resolve the issue but no luck.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,068 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,187 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jiachen Li-MSFT 33,196 Reputation points Microsoft Vendor
    2023-08-15T01:47:50.1833333+00:00

    Hi @Sridhar Reddy Arjula ,

    Try cleaning up your project's publish directory before publishing it.

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Aakash Hase 0 Reputation points
    2025-01-04T14:28:45.5533333+00:00

    Right click on project in vs studio.

    Select Manage NuGet Packages

    browse Online "System.ServiceController" Package

    If Version 9.0.0 or higher is installed, then uninstall it

    Now Select Version 8.0.1. And Install it.

    I have the same issue. And i ended up downgrading System.ServiceController from v9.0.0 to v8.0.1.

    I think in V 9.0.0 there are many restrictions applied.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.