J
Just close your eyes and see
Hello all
i am trying to learn how to program a windows service application
i had add an event log and a timer that used to write to file
here is the code
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
timer1.Start();
}
protected override void OnStop()
{
eventLog1.WriteEntry("In onStop");
timer1.Stop();
}
protected override void OnContinue()
{
eventLog1.WriteEntry("In OnContinue");
timer1.Start();
}
FileStream fs;
StreamWriter sw;
private void timer1_Tick(object sender, EventArgs e)
{
fs = new FileStream(@"C:\tem.txt", FileMode.OpenOrCreate, FileAccess.Write);
sw = new StreamWriter(fs);
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine(DateTime.Now.ToString());
sw.Flush();
sw.Close();
}
and i had added an installer to install the windows service, i followed the
instructions that is in the MSDN
http://msdn.microsoft.com/en-us/library/zt39148a(VS.80).aspx
first it works and installed but when i tried to run it from the windows
management console
it run and ends immediatly and i got a message telling me that some services
closed coze it is not doing anything
when i tried to make a new installation package, and reninstall the service,
the installation package failed to install the service and give me 2 messages
the first one saying that source of the service is on the local machine
and finally i got a meesage that the installation is interupted and ended
not successfuly
plz help to resolve that.....
i am trying to learn how to program a windows service application
i had add an event log and a timer that used to write to file
here is the code
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
timer1.Start();
}
protected override void OnStop()
{
eventLog1.WriteEntry("In onStop");
timer1.Stop();
}
protected override void OnContinue()
{
eventLog1.WriteEntry("In OnContinue");
timer1.Start();
}
FileStream fs;
StreamWriter sw;
private void timer1_Tick(object sender, EventArgs e)
{
fs = new FileStream(@"C:\tem.txt", FileMode.OpenOrCreate, FileAccess.Write);
sw = new StreamWriter(fs);
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine(DateTime.Now.ToString());
sw.Flush();
sw.Close();
}
and i had added an installer to install the windows service, i followed the
instructions that is in the MSDN
http://msdn.microsoft.com/en-us/library/zt39148a(VS.80).aspx
first it works and installed but when i tried to run it from the windows
management console
it run and ends immediatly and i got a message telling me that some services
closed coze it is not doing anything
when i tried to make a new installation package, and reninstall the service,
the installation package failed to install the service and give me 2 messages
the first one saying that source of the service is on the local machine
and finally i got a meesage that the installation is interupted and ended
not successfuly
plz help to resolve that.....