Link to home
Create AccountLog in
Avatar of Christoff Botes
Christoff BotesFlag for South Africa

asked on

Need help with Windows Service not running

Hi Experts,

I have written a windows service to perform several tasks for my client a few times a day.

I first wrote the thing as a normal exe and then converted it to a Service.  The code works fine.   I was also able to install and start the service on a testing PC.

My problem is that none of the code inside my service seem to fire...   I have a timer control with interval of 10 000 ms.  In the OnStart event I set the timer's enabled property to true.  Inside the timer's tick event is all my code.

I noticed that nothing that should be happening is happening.  So I put a line of code to write an entry into the Windows event log from the OnStart event of the service and from the Tick event of the timer.  The OnStart entry is always there when the service starts but the Tick entry is never there.

This is driving me mad!!!

Please assist.  I'm allocating 500 points because I am close to going mad and I need to finish this urgently.

Thanks
Avatar of Christoff Botes
Christoff Botes
Flag of South Africa image

ASKER

Experts,

I can add the following information for you:

I am developing on a Vista machine with VS2005 on Framework 2.0.

I am deploying and testing on Win XP Pro SP2  with Dot net 2.0 and Crystal Runtime installed.

My application does the following:
  -Read XML file to get setttings
  -Create folder in application path
  -Query SQL Server
  -If records are returned from the query, run a crystal report for each record.  An rpt file is opened
     from the application path.  The selection formula is changed using the record from SQL.
  -The report is exported to a PDF into a temp folder inside the application path
  -The PDF is mailed to a specific e-mail address using SMTP.

Dont know if thats gonna help.

Let me know if you need more

Thanks
ASKER CERTIFIED SOLUTION
Avatar of mastoo
mastoo
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thanks !!!
Thank you Mastoo!

Changing to a different timer did the trick.  I would have never guessed that one!  I used Timers.Timer.

I also didn't know that one could attach the debugger to a service.  That would be really handy someday!!!  I tried it but I cant seem to get it working....

From your link:
>>>>Once the service is started (and the installed service is a debug build), start your IDE .....

I assume that the service has to be compiled and then installed as a service on the same computer as the source code.  I've done this.  Not sure what you mean with a "debug build"?  Also, I have no Attach to Process option in my Debug menu.  Maybe I'm using the wrong debug menu....

Thanks for your effort.  You really helped a lot!
Thanks again
Glad that helped.  I had somebody else tell me they didn't have that option on their Debug menu.  That would make it hard to do.  Maybe you can get to that option by Tools - customize - commands - Debug - Attach to Process;  this might let you add it to the menu otherwise maybe it is a version thing like you suggest.  And if you get that far, yes you build and install and debug all on the same computer.  Good luck.
Sorry to keep this going but what is a "debug build"  ?

Thanks
Projects (and solutions) have different configurations you can build - Debug, Release, custom, etc.  You've usually got a listbox with these choices labeled as configuration.  The reason I mention it is that you can attach a debugger to a release build, but release builds don't include debugging info so it doesn't work very well.  The debug configuration or debug build includes a bunch of info for the debugger.  Right-click your solution and choice configuation manager and you'll see the different builds you can do.  Then look at the properties of a project and change between debug and release and you'll see various build options change.
Thank you