Tuesday, October 17, 2006

Windows Service in VS2005 ??

Had you ever stuck up in creating windows Service in vs2005 ??
Like any other Person , you must have also wondered why the template for creating Windows Service is absent in VS2005.
I was also the one.
But after some research i found that , VS2005 is not provided with the Template for creating windows service in VS2005.
In order to create a Windows Service in VS2005 , follow the Below steps:
1. Create an empty project.
2. Save the project.
3. Add system.ServiceProess and System.Configuration.Install Dll references.
4.Now you need to add 2 class files to ur project.
5.windowsServcie.cs and windowsServiceInstaller.cs
6.Add the below code using statement to windowsService.cs:
using System.Diagnostics;using System.ServiceProcess;
namespace WindowsService{ class WindowsService : ServiceBase { }
7. add the below using statements code to windowsserviceinstaller.cs:
using System;
using System.ComponentModel;using System.Configuration.Install;using System.ServiceProcess;
namespace WindowsService{ [RunInstaller(true)] public class WindowsServiceInstaller : Installer { /// /// Public Constructor for WindowsServiceInstaller. /// - Put all of your Initialization code here. /// public WindowsServiceInstaller() { } }

8. Now add all the code as like VS2003 , which u like to add for the windows service.

Thanks
Senthil

4 comments:

Anonymous said...

Hi Maverick,
I guess you might have not installed the complete version. Check your version ??
Yes here I'm getting Windows Service appearing in my project Templates(VS 2005 Editor) and able to create windows service without any probs.

Here is my VS 2005 details.
* MS VS 2005- Professional Edition (Version 8.0.50727.42) RTM Framework version 2.0.50727
Check your Version against this and let me know.
Here is the steps followed while creating Windows Service in VS 2005.
Step 1) Add New project > Visual C# > Windows > Select Windows Service from Templates
2) You will get a screen with Serivice1.cs as default page.
3) Now you have to manually add installer by rightclickin on the Service form.
4) It will add (serviceProcessInstaller1,serviceInstaller1) to the Service form.
5) Now place your code on events what ever you want.

Hope this version & settings will ease your Win Service creation, else ping me online.

Mahesh~

SenthilVel M said...

Mahesh , I shall check this

Anonymous said...

http://www.johnchow.com/index.php/other-advertising-networks-besides-google-adsense/

Anonymous said...

Oh sure.
Mahesh