Click here to Skip to main content
15,917,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, I am new to VS, and just created my first console application (no not Hello World) haha. Now I need it to be a service. It will run on 2003 and 2008 Windows servers. Is there some conversion process I can use in 2005 or will I have to start from scratch? Thank you in advance!

Pertinent's:

Visual Studio 2005 C# Console Application.

The program seeks out batch files and executes them. Also deletes ones previously used before finding the new ones.

I've tried running it under scheduled tasks but it doesn't seem to repeat using that method.
Posted
Comments
[no name] 9-Apr-13 11:59am    
You would need to create a service project. Then you could try and copy/paste your existing code into the service but it probably is not going to be that easy. Services have their own peculiarities. There is no direct "conversion" from one project type to another.

Hi Sandra,

Add a reference to System.ServiceProcess.ServiceBase to your console application and implement your class like this.

C#
public class WinService1 : System.ServiceProcess.ServiceBase


Follo the steps in the below link to implement code for OnStart, OnStop and other methods.

http://www.c-sharpcorner.com/UploadFile/mahesh/window_service11262005045007AM/window_service.aspx[^]

Happy coding :)

Regards,
Manoj
 
Share this answer
 
Look at the following article; Simple Windows Service Sample[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900