473,385 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Windows Service Problems

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/libr...8VS.80%29.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.....

Sep 30 '08 #1
2 1037
I would say it must have thrown an expection in the logging to the event log.
Have you checked that part of the code and made sure you are using a valid
source for the event log entries etc?

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Just close your eyes and see" wrote:
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/libr...8VS.80%29.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.....
Sep 30 '08 #2
here is my constructor code where i had initialized the event log

InitializeComponent();
if (!EventLog.SourceExists("TSNUpdatingWebApp"))
{
EventLog.CreateEventSource("TSNUpdatingWebApp",
"TSNUpdatingWebApp");
}
eventLog1.Source = "TSNUpdatingWebApp";
eventLog1.Log = "TSNUpdatingWebApp";
Sep 30 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stefan Hinz | last post by:
Degan, jumping in to try and solve some problems that look pretty obvious to me ... > #options for default service (mysqld2) > (mysqld2) It should be , not (mysqld2).
2
by: cd | last post by:
Is there a specific process or permissions that must be granted to get a .NET (framework 1.4) Window Service to run properly on a Windows 2003 Server? I built a Windows Service to start two local...
7
by: Lalit | last post by:
Hi Friends, I have developed a Windows service. Now i need icon for this service in systray and context menu fo this icon. Can i do this? With regards, Lalit
4
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group :...
2
by: Jesper Stocholm | last post by:
I have created a simple service which just copies a fil to a new file with a new name on certain intervals (the service implements a timer). I have no problems installing the service and the...
1
by: Samuel R. Neff | last post by:
We're using a 3rd party C DLL in a project that we don't have source for. When we call the DLL from a console app everything works fine. However, when we call it from a Windows Service, the DLL...
10
by: Ger | last post by:
I am having problems using VB.Net's Management base object on a machine hosting Windows Server 2003. I am trying to set file permissions from a Windows Service. These files may be loacted on a...
2
by: Tom | last post by:
Hi, We have a web service (developed in C# framework 1) that run for some time on Windows 2000. Recently we upgraded it to framework 2 and run successfully on Windows 2000 and XP. However, we...
6
by: Chris Marsh | last post by:
All I have a database table, changes to the data within which I am interested in acting on. The approach that I'm taking is to have the database update a file every time data is updated. This...
0
by: =?Utf-8?B?U2ltb25EZXY=?= | last post by:
Hi All I would like to install the same Windows Service project on the same server under different names, one for each customer. I have been able to do it but I would like an expert opinion as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.