Hello All,
We have requirement that need to convert existing console application to windows service same code setup.
what is the process to create windows service and publish in the windows service.
Regards
Anand.
Hello All,
We have requirement that need to convert existing console application to windows service same code setup.
what is the process to create windows service and publish in the windows service.
Regards
Anand.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Naimish MakwanaRank #324 · 7.7K reputationPosted Aug 14, 2024, 12:45 AM EDT
Converting a console application to a Windows service involves a few steps. Here’s a high-level overview of the process:
Create a new Windows Service project: In your solution, select Add, and Click New Project. Select the Windows Service (.NET Framework) template1.
Add an installer for the Windows Service: This installer registers the service with the control manager. You can add an installer by right-clicking on the blank area and selecting "Add installer"2.
Update the service name, display name, and description of the service: You can do this in the
ProjectInstaller.Designer.cs=>InitializeComponent()method2.Implement the real service: Open your service class (in my case
MyWindowService.Designer.cs) and you should have two default methods -OnStart&OnStop (). Use an event logger to log the Windows Service information2.Integrate your console app code into the Windows Service structure: The most straightforward approach is to create a new Windows Service to have the right structure of your main entry point and the correct references, then integrate your console app code into that structure3.
Install the Windows Service: You can use the
installutil.exetool that comes with .NET Framework to install your Windows Service. The command would look something like this:installutil.exe YourService.exe.Refer below links:
https://www.c-sharpcorner.com/blogs/how-to-convert-existing-c-sharp-application-to-window-service
https://stackoverflow.com/questions/15493603/how-to-convert-a-console-application-to-a-windows-service
Thanks