Hi,
I want to run a window service as soon as the system get start automatically. I have made a service it is working properly but the problem is that when i shutdown the system and come next day and start the system, the service is not started. I have to manually start the service but when i try and check by restarting the system, the service is started only. Please can anyone suggest!!!
Loading

Guest UserPosted May 13, 2011, 9:07 AM
http://joefreeman.co.uk/blog/2010/03/creating-a-setup-project-for-a-windows-wcf-service-with-visual-studio/
When you run the msi that will be created when you build your setup project, the information in ProjectInstaller1 will be used to establish the dependency.
Vijay YadavPosted May 16, 2011, 2:45 AM
VulpesPosted May 13, 2011, 12:07 PM
Suthish NairPosted May 13, 2011, 11:53 AM
Guest UserPosted May 13, 2011, 11:30 AM
Vijay YadavPosted May 13, 2011, 10:08 AM
Thanks a lot!!!
It is working fine now... :)
Guest UserPosted May 13, 2011, 9:18 AM
The serviceInstaller1 component is where you set the DisplayName and Description of your service (the text that appears in the Administrative Tools->Services list), and the startup type (manual/automatic/disabled). You should still use Automatic, but with the dependency to SQL Server in place it should start correctly.
Guest UserPosted May 13, 2011, 9:13 AM
Vijay YadavPosted May 13, 2011, 8:41 AM
You are right my service is geeting start before sql server starts. As you suggested to create an installer (i.e. a setup project) for the service. As far as i understood, i have to just create a setup. Can you please ellaborate the same. Thanks a lot!
Guest UserPosted May 13, 2011, 8:34 AM
It's also possible that your service is starting before the SQL Server service has been started. If that's the case, then you will need to establish a dependency for your service so that it won't try to start before SQL Server. You can do this by creating an installer (i.e. a setup project) for your service.
Vijay YadavPosted May 13, 2011, 7:28 AM
Thanks for your kind reply.
@Suthish- I tried your way but it doesn't worked out.
And the problem is that onstart of service i am retrieving data from database.
As John and Mahesh suggested for exception handling, I am writing the exception in the local file and it is showing
"Cannot open database "database_ name" requested by the login. The login failed. Login failed for user 'sa'" on start of the computer. That means it is not able to retrieve the data on start of the service when the system start again but now the service is getting started as i changed the account from network service to local system. Please help!
Suthish NairPosted May 13, 2011, 2:19 AM
An alternative solution
Mahesh ChandPosted May 12, 2011, 5:56 PM
This is possible that your service is trying to run but getting an exception. If an exception occurs, it won't start. Try to put a try..catch in your code within the service and if exception occurs, write in a local text file. This was one of the way I used to diagnose my windows service problems.
Guest UserPosted May 12, 2011, 5:51 PM
You really should add some error logging to your service. Some possibilities are log4net and Elmah.
You won't be able to fix your problem until you find out what's causing it, and to do that you have to catch the exceptions being thrown and track down their cause(s).
Guest UserPosted May 12, 2011, 5:48 PM
Vijay YadavPosted May 12, 2011, 8:47 AM
and
@Sam i also don't understand what's there in system event logs.
Vijay YadavPosted May 12, 2011, 8:19 AM
And Mahesh, i done this but then also it is not working. You can see the images of the service in the attached file.
One is when i start the service and another is when i shutdown and start the system again but service didn't get start.
Please help!!!
Mahesh ChandPosted May 11, 2011, 11:05 PM
Find your services name, right click on it, select Properties.
On General tab, make Startup Type = Automatic.
Sam HobbsPosted May 11, 2011, 9:49 PM
Guest UserPosted May 11, 2011, 12:24 PM
One possibility is that the service is attempting to access areas of the file system that the account it's running under does not have access to. As a test, try changing the service's logon account to one with local admin rights to see if that fixes the problem (using the "Log On" tab of the service properties dialog). If the service runs normally, then you should create another local account with the minimum permissions it needs to access those areas of the file system. Don't let it use an admin account for production use as that may introduce security issues.
VulpesPosted May 11, 2011, 11:43 AM
I'd make sure that you've installed all the latest updates and, if you're using Vista, I'd see if there's anything which helps in this thread (http://social.technet.microsoft.com/forums/en-US/itprovistasetup/thread/cc3ce627-9a7e-4887-a793-edd66b70ea3e/).
Vijay YadavPosted May 11, 2011, 11:24 AM
I have set the StartType propety to Automatic but hten also it is nt getting started.
Any other idea?
VulpesPosted May 11, 2011, 11:17 AM