Incase you haven't seen the previous tutorial, then below is the link:
How to create a windows service
Once we are done with creating a windows service, we need to install the windows service using one of the two options: one is using InstallUtil.exe tool or using a setup.In the videos below we will see how to create a setup project and create setup installer for our windows services.
Regards
Sameer Shaik
Free Online Training VIDEOS,SAMPLES,TUTORIALS ON MCTS EXAM C#.NET(MS VISUAL STUDIO) Thanks for your support. The blog is getting bigger and better day by day. please check out : www.blog.sameershaik.com for further interesting articles on other microsoft certification examinations
Search this blog
You can search for all the topics in our blog using our google custom search now.
Search the blog
Loading
Sunday, July 25, 2010
How to create a windows service
Free Microsoft MCTS 70-536 Examination Training and Preparation for Jobs
Window services are applications which run in background with no user interaction.We can create these services for many purposes like tracking the changes done to the files in a particular folder for example.In our example, we will be creating a windows service, which will create a text document at certain location on our local computer and writes the status of our service along with the time stamp.
Below is the code for the same.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.IO;
namespace WsEg1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
FileStream fs = new FileStream(@"C:\My stuff\Work Stuff\Pdf\ServiceInfo.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("Service has been started at " + System.DateTime.Now);
sw.Close();
fs.Close();
}
protected override void OnStop()
{
FileStream fs = new FileStream(@"C:\My stuff\Work Stuff\Pdf\ServiceInfo.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("Service has been stopped at " + System.DateTime.Now);
sw.Close();
fs.Close();
}
}
}
After creating windows service we will add an installer to the project which will have the configuration information of our windows service.To know how you can an installer to a windows service, please check the video.
Regards
Sameer Shaik
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test
Window services are applications which run in background with no user interaction.We can create these services for many purposes like tracking the changes done to the files in a particular folder for example.In our example, we will be creating a windows service, which will create a text document at certain location on our local computer and writes the status of our service along with the time stamp.
Below is the code for the same.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.IO;
namespace WsEg1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
FileStream fs = new FileStream(@"C:\My stuff\Work Stuff\Pdf\ServiceInfo.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("Service has been started at " + System.DateTime.Now);
sw.Close();
fs.Close();
}
protected override void OnStop()
{
FileStream fs = new FileStream(@"C:\My stuff\Work Stuff\Pdf\ServiceInfo.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("Service has been stopped at " + System.DateTime.Now);
sw.Close();
fs.Close();
}
}
}
After creating windows service we will add an installer to the project which will have the configuration information of our windows service.To know how you can an installer to a windows service, please check the video.
Regards
Sameer Shaik
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test
Subscribe to:
Posts (Atom)