By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,533 Members | 2,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,533 IT Pros & Developers. It's quick & easy.

Windows service with timer doesn't work in Windows 2003 server

P: n/a
Hi all,

I have developed a windows service using the windows service project
template in VS.NET. I have used three controls in the service, a timer,
performance counter and a message queue control. The service will "sleep"
for 'n' seconds using the timer control and whenever the timer_elapsed event
occurs, I use the performance counter object to determine availability of
few resources. Based on the availability of resources, I use the message
queue control to put messages into a local private queue. The service uses
LocalService account and reads a few registry keys in the OnStart() method
and then waits for the timer_elapsed event.

The issue is the all too familiar "it works on my system" kind!! It works
perfectly fine in my development system (installed using installutil) which
is a WinXP SP2 with .Net 1.1.4322 and the timer also gets triggered
properly. But when I install the same service in a Windows 2003 server the
timer never gets triggered!! The server also has the same version of .Net
framework but I'm just lost as to why the timer doesn't get triggered
there!! There are no errors/warnings generated in the event log too so its
all the more confusing. I also tried creating a setup project with custom
actions and then installed the same in the Win2003 server but the
timer_elapsed event never gets triggered!!

Replies will be very helpful!! Btw, I have set the AutoReset property of
the timer control to false to have control over when the timer starts
ticking again, but I have made sure that I start off the timer
appropriately.

Thanks
Dhilip Kumar
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Silly question but you are using a System timer and not a form's timer
right?

Also, what, if any, additional processing does the service do that might
be causing a security issue under the server environment. I agree,
service debugging is a pain.

What I do, while making the code a pain in the ass to read, is add
literally about 100 of these

#if _SERVICE_DEBUG_
eventLog.Additem("[method]::[counter]");
#endif

so that I will see "eventLog.Additem("_addHash::11");" in my code and
about 5-6 lines below that "eventLog.Additem("_addHash::12");".

It's a sad yet, fully workable way to watch line by line count what is
going on log wise in the service. When you see 10.11.12.. and no more
numbers, it pins down the cause between 12 and 13. When your finished
just undefine the pragma and recompile to get rid of the tracking.

Dhilip Kumar wrote:
Hi all,

I have developed a windows service using the windows service project
template in VS.NET. I have used three controls in the service, a timer,
performance counter and a message queue control. The service will "sleep"
for 'n' seconds using the timer control and whenever the timer_elapsed event
occurs, I use the performance counter object to determine availability of
few resources. Based on the availability of resources, I use the message
queue control to put messages into a local private queue. The service uses
LocalService account and reads a few registry keys in the OnStart() method
and then waits for the timer_elapsed event.

The issue is the all too familiar "it works on my system" kind!! It works
perfectly fine in my development system (installed using installutil) which
is a WinXP SP2 with .Net 1.1.4322 and the timer also gets triggered
properly. But when I install the same service in a Windows 2003 server the
timer never gets triggered!! The server also has the same version of .Net
framework but I'm just lost as to why the timer doesn't get triggered
there!! There are no errors/warnings generated in the event log too so its
all the more confusing. I also tried creating a setup project with custom
actions and then installed the same in the Win2003 server but the
timer_elapsed event never gets triggered!!

Replies will be very helpful!! Btw, I have set the AutoReset property of
the timer control to false to have control over when the timer starts
ticking again, but I have made sure that I start off the timer
appropriately.

Thanks
Dhilip Kumar

Nov 16 '05 #2

P: n/a
Greg,

Thanks very much for your reply. Yes, it was a security issue! The timer
control I used was a server timer, but I was using Local Service account. I
changed it to LocalSystem it worked! Interesting, because I don't recollect
seeing any security precautions in the documentation while using the server
timer!!

Dhilip Kumar

"Greg Merideth" <be*****@forwardtechnology.net> wrote in message
news:41**************@forwardtechnology.net...
Silly question but you are using a System timer and not a form's timer
right?

Also, what, if any, additional processing does the service do that might
be causing a security issue under the server environment. I agree,
service debugging is a pain.

What I do, while making the code a pain in the ass to read, is add
literally about 100 of these

#if _SERVICE_DEBUG_
eventLog.Additem("[method]::[counter]");
#endif

so that I will see "eventLog.Additem("_addHash::11");" in my code and
about 5-6 lines below that "eventLog.Additem("_addHash::12");".

It's a sad yet, fully workable way to watch line by line count what is
going on log wise in the service. When you see 10.11.12.. and no more
numbers, it pins down the cause between 12 and 13. When your finished
just undefine the pragma and recompile to get rid of the tracking.

Dhilip Kumar wrote:
Hi all,

I have developed a windows service using the windows service project
template in VS.NET. I have used three controls in the service, a timer,
performance counter and a message queue control. The service will
"sleep" for 'n' seconds using the timer control and whenever the
timer_elapsed event occurs, I use the performance counter object to
determine availability of few resources. Based on the availability of
resources, I use the message queue control to put messages into a local
private queue. The service uses LocalService account and reads a few
registry keys in the OnStart() method and then waits for the
timer_elapsed event.

The issue is the all too familiar "it works on my system" kind!! It
works perfectly fine in my development system (installed using
installutil) which is a WinXP SP2 with .Net 1.1.4322 and the timer also
gets triggered properly. But when I install the same service in a
Windows 2003 server the timer never gets triggered!! The server also has
the same version of .Net framework but I'm just lost as to why the timer
doesn't get triggered there!! There are no errors/warnings generated in
the event log too so its all the more confusing. I also tried creating
a setup project with custom actions and then installed the same in the
Win2003 server but the timer_elapsed event never gets triggered!!

Replies will be very helpful!! Btw, I have set the AutoReset property of
the timer control to false to have control over when the timer starts
ticking again, but I have made sure that I start off the timer
appropriately.

Thanks
Dhilip Kumar

Nov 16 '05 #3

P: n/a

"Dhilip Kumar" <dd*****@gmail.com> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...
Greg,

Thanks very much for your reply. Yes, it was a security issue! The timer
control I used was a server timer, but I was using Local Service account.
I changed it to LocalSystem it worked! Interesting, because I don't
recollect seeing any security precautions in the documentation while using
the server timer!!

Dhilip Kumar


There are no security issues associated, both LocalSystem and Local service
should work.
What scares me a bit is that you are talking about a "Time Control" using
"server timer", mind to explain exactly what control you are talking about?
More importantly, what timer class are you using?

Willy?

Nov 16 '05 #4

P: n/a
Willy,

I am using timer instance from the Server.Timers namespace. I hope that
should be fine!

Dhilip

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...

"Dhilip Kumar" <dd*****@gmail.com> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...
Greg,

Thanks very much for your reply. Yes, it was a security issue! The
timer control I used was a server timer, but I was using Local Service
account. I changed it to LocalSystem it worked! Interesting, because I
don't recollect seeing any security precautions in the documentation
while using the server timer!!

Dhilip Kumar


There are no security issues associated, both LocalSystem and Local
service should work.
What scares me a bit is that you are talking about a "Time Control" using
"server timer", mind to explain exactly what control you are talking
about?
More importantly, what timer class are you using?

Willy?

Nov 16 '05 #5

P: n/a
Guess you mean System.Timers namespace. Using this kind of timers should
work without a problem irrespective the security context.
I'm sure you hit another issue with your service.

Willy.

"Dhilip Kumar" <dd*****@gmail.com> wrote in message
news:uV****************@TK2MSFTNGP10.phx.gbl...
Willy,

I am using timer instance from the Server.Timers namespace. I hope that
should be fine!

Dhilip

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...

"Dhilip Kumar" <dd*****@gmail.com> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...
Greg,

Thanks very much for your reply. Yes, it was a security issue! The
timer control I used was a server timer, but I was using Local Service
account. I changed it to LocalSystem it worked! Interesting, because I
don't recollect seeing any security precautions in the documentation
while using the server timer!!

Dhilip Kumar


There are no security issues associated, both LocalSystem and Local
service should work.
What scares me a bit is that you are talking about a "Time Control" using
"server timer", mind to explain exactly what control you are talking
about?
More importantly, what timer class are you using?

Willy?


Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.