This project is read-only.

Failed to start service

May 15, 2007 at 1:25 PM
I installed PolyMon Executive, PolyMon Manager, and SQL 2005 Express on an XP Professional machine to test PolyMon before trying it on a production server. I've hit a few bumps along the road, but nothing too difficult to correct, until I noticed something. It most likely is something I messed up, which is why I'm not putting this in Issue Tracker, but when I reboot the machine PolyMon is on, the service always fails to start. The error details are as follows:

Event Type: Error
Event Source: PolyMonExecutive
Event Category: None
Event ID: 0
Date: 5/15/2007
Time: 8:13:19 AM
User: N/A
Computer: LCS-XKV6DQO70SZ
Description:
Service cannot be started. System.ArgumentException: Service name contains invalid characters, is empty, or is too long (max length = 80).
at System.ServiceProcess.ServiceControllerPermissionEntry..ctor(ServiceControllerPermissionAccess permissionAccess, String machineName, String serviceName)
at System.ServiceProcess.ServiceControllerPermission..ctor(ServiceControllerPermissionAccess permissionAccess, String machineName, String serviceName)
at System.ServiceProcess.ServiceController.Stop()
at PolyMon.Executive.PolyMonExecutive.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

I used the default directory for the installation, so the service is at "C:\Program Files\PolyMon\PolyMon Executive (RC3)\PolyMonExecutive.exe". I don't know diddly squat about .Net, so none of the above makes any sense to me. I am posting this in hopes that this is something painfully obvious to someone out there, and you can tell me what I did wrong.
May 15, 2007 at 2:01 PM
Is PolyMon Manager running OK? (i.e. are you able to create monitors, test run them ,etc) or is that having problems too?

Also, please go to the services console and right click /Properties. What is the Service Name? Display Name? From the error message it sounds like it does not like the Service Name... I'm wondering if the service name got corrupted during the installation process... (Which release are you using and did you use the install binaries or are you compiling the sources yourself?)
May 15, 2007 at 2:13 PM
I've noticed some sql express errors as well, after digging a little deeper. Immediately following one of the failed attempts to start PolyMon Executive I saw this:

Event Type: Failure Audit
Event Source: MSSQL$SQLEXPRESS
Event Category: (4)
Event ID: 18456
Date: 5/15/2007
Time: 8:42:41 AM
User: LEBANON-CSD\username
Computer: LCS-XKV6DQO70SZ
Description:
Login failed for user 'LEBANON-CSD\username'. CLIENT: <local machine>

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 18 48 00 00 0e 00 00 00 .H......
0008: 1b 00 00 00 4c 00 43 00 ....L.C.
0010: 53 00 2d 00 58 00 4b 00 S.-.X.K.
0018: 56 00 36 00 44 00 51 00 V.6.D.Q.
0020: 4f 00 37 00 30 00 53 00 O.7.0.S.
0028: 5a 00 5c 00 53 00 51 00 Z.\.S.Q.
0030: 4c 00 45 00 58 00 50 00 L.E.X.P.
0038: 52 00 45 00 53 00 53 00 R.E.S.S.
0040: 00 00 07 00 00 00 6d 00 ......m.
0048: 61 00 73 00 74 00 65 00 a.s.t.e.
0050: 72 00 00 00 r...

I have replaced my actual username with "username", but the user:pass is correct, and has domain admin rights. My SQL Express installation is using Windows Authentication, and I am able to login to SQL Management Studio without any problems. Sometimes the error above shows up, and other times I see this error:

Event Type: Error
Event Source: MSSQL$SQLEXPRESS
Event Category: (4)
Event ID: 17187
Date: 5/15/2007
Time: 7:36:38 AM
User: N/A
Computer: LCS-XKV6DQO70SZ
Description:
SQL Server is not ready to accept new client connections. Wait a few minutes before trying again. If you have access to the error log, look for the informational message that indicates that SQL Server is ready before trying to connect again. CLIENT: <local machine>

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 23 43 00 00 10 00 00 00 #C......
0008: 1b 00 00 00 4c 00 43 00 ....L.C.
0010: 53 00 2d 00 58 00 4b 00 S.-.X.K.
0018: 56 00 36 00 44 00 51 00 V.6.D.Q.
0020: 4f 00 37 00 30 00 53 00 O.7.0.S.
0028: 5a 00 5c 00 53 00 51 00 Z.\.S.Q.
0030: 4c 00 45 00 58 00 50 00 L.E.X.P.
0038: 52 00 45 00 53 00 53 00 R.E.S.S.
0040: 00 00 00 00 00 00 ......


I don't see a pattern as to which error I get when, but it always seems to be one or the other.
May 15, 2007 at 2:26 PM
I installed RC3 using the default settings. PolyMon Manager runs great (new TCP port monitor works for me, thanks!), and I can manually start PolyMon Executive, and it runs fine until the next reboot, when it fails to start automatically. The Service Name and Display Name are both PolyMonExecutive. If I were to reinstall, would the monitor definitions I have setup disappear?
May 15, 2007 at 2:37 PM
I just found out my system did the exact same thing. I pulled up PolyMon Manager and noticed no tests had been run since May 9th. I logged into the server the Executive service is on and saw the service wasn't started. Going back through the errors I got the exact same one as Derekius above (same stack trace too), but when I choose to start the service manually it starts up right away.

I have decent familiarity with .Net and Windows Services, but not with .Net and writing services. I'm going to try looking at the code to see if I can find anything out but does anyone else have this trouble?
May 15, 2007 at 3:00 PM
Correct me if I'm wrong but it sounds like you are both able to succesfully start the service manually once your machine has booted up.

In that case, I'm wondering if there is a dependency issue. PolyMon Executive needs the SQL Server service to be running in order to start succesfully... It may very well be attempting to start before the SQL Service has succesfully started. I think there is a way to specify the order in which services should be started - if anyone already knows this it would be much appreciated.
If the start order cannot be defined, I will have to see how I can have polymon executive still start and just keep trying to connect to the database until a succesful connection has been made. It has not been an issue for me because my database server is on a separate machine.
May 15, 2007 at 3:35 PM
I thought the same thing. If the sql server is not accepting any connections, then the polymon service should fail, and it does. I went to the Recovery tab and set it so the first failure would cause the service to restart, same for the second failure, and the third failure would reboot the machine. Unfortunately, it didn't seem to do any of that. :-p
May 15, 2007 at 3:35 PM
Edited May 15, 2007 at 3:39 PM
For some reason my message posted twice, and i dont see a delete option. I doubt it would help, but I tried to edit the connection string in the executive config file to use specific credentials to connect to the sqlexpress db, but i dont know enough about connection strings to get it to work. My goal was to have the service run as Local System, and use a domain admin user/pass to connect to the db. Any idea on the syntax of the connection string to remove integrated authentication, and specify credentials (SQLEXPRESS is using Windows Authentiction)
May 15, 2007 at 3:48 PM
This might help:

http://bloggingabout.net/blogs/jschreuder/archive/2006/12/07/How-to3A00-Code-Service-Dependencies.aspx

I can see just adding an AppSetting variable in the config file that says whether dependencies are enable, and if so what the name of the dependency should be (or searching for something with Microsoft SQL Server in the name). If they are enabled, run that line that makes the service dependent and if not, then don't.
May 15, 2007 at 4:10 PM
For whatever reason the link I pasted above isn't working. Here is the Google search I did, and it should be the 6th entry down (Jan Schreuder's blog):

http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=M6I&q=.netwindowsservice+dependency&btnG=Search
May 15, 2007 at 8:50 PM
Using SC.exe (http://support.microsoft.com/kb/251192), I was able to add a dependency to PolyMonExecutive, but that didnt seem to make a difference.
May 15, 2007 at 9:06 PM
I'm not sure why I overlooked this before...in the data portion of the event that is written to the Application log for the SQL login failure, it does not show PolyMon, but instead says "master". I dont know where to go from here, but if I understand this right, it looks like the PolyMon Executive service is trying to open the master database (there is also a log about dedicated administrator connection support being disabled, but I don't know if it is relevant). In case you haven't noticed, I'm the kind of person that does not stop until I get things figured out.
May 15, 2007 at 9:28 PM
Good place for SQL connection strings is here:
http://www.sqlstrings.com/SQL-Server-connection-strings.htm

Note that you are looking for the .NET connection strings in this case.

In order to use a User ID/Password for connecting to SQL, you will need to make sure it is set up to allow mixed mode authentication (not just Windows authentication, otherwise I believe your only option is to use a trusted connection).


Derekius wrote:
For some reason my message posted twice, and i dont see a delete option. I doubt it would help, but I tried to edit the connection string in the executive config file to use specific credentials to connect to the sqlexpress db, but i dont know enough about connection strings to get it to work. My goal was to have the service run as Local System, and use a domain admin user/pass to connect to the db. Any idea on the syntax of the connection string to remove integrated authentication, and specify credentials (SQLEXPRESS is using Windows Authentiction)

May 15, 2007 at 9:32 PM
I believe that simply adding a dependency may not be sufficient - although the SQL service may have "started" it is still not in a position to respond to authentication requests and queries. I think I still need to add a mechanism in PolyMon Executive that simply keeps trying to connect to the SQL Server until successful - I used to have that in place and removed it in a more recent version - obviously needs to go back in :-(
My only problem with that (and the reason I took it out without thinking all the way through) is that the PolyMon Executive service will successfully "start" even though it may not have a database to talk to - this would in essence be a silent fail.



Derekius wrote:
Using SC.exe (http://support.microsoft.com/kb/251192), I was able to add a dependency to PolyMonExecutive, but that didnt seem to make a difference.

May 15, 2007 at 9:38 PM
There is no particular reason PolyMon would try to "open" the master database. This is probably something SQL does internally during the authentication process (master after all is used to control many aspects in SQL).
You are right that the dedicated administrator connection support is not relevant in this case.

If you are using SQL with windows authentication, then the service account PolyMon Executive is running under will need dbo privileges to the PolyMon database. If you are using mixed mode authentication, then you will need to create a SQL user account with dbo privileges to the database and use these credentials in the connection string of PolyMon executive.

When running PolyMon manager and using integrated security, your login credentials (i.e. who you are logged in as on the workstation) is what gets passed to SQL. When running through Executive, the account the service runs under is what gets passed to SQL.


Derekius wrote:
I'm not sure why I overlooked this before...in the data portion of the event that is written to the Application log for the SQL login failure, it does not show PolyMon, but instead says "master". I dont know where to go from here, but if I understand this right, it looks like the PolyMon Executive service is trying to open the master database (there is also a log about dedicated administrator connection support being disabled, but I don't know if it is relevant). In case you haven't noticed, I'm the kind of person that does not stop until I get things figured out.

May 15, 2007 at 9:43 PM
The dependency must essentially be set at installation time (it's a registry setting).
Also I cannot simply add the dependency in blanket fashion because polymon executive need not run on the same server as the SQL server.

What I really need to do is make sure that the executive service keeps trying to establish a connection to the sql server until either (a) a connection is established or a pre-determined limit (defined in .config) attempts is reached.

Thanks.



digitall wrote:
This might help:

http://bloggingabout.net/blogs/jschreuder/archive/2006/12/07/How-to3A00-Code-Service-Dependencies.aspx

I can see just adding an AppSetting variable in the config file that says whether dependencies are enable, and if so what the name of the dependency should be (or searching for something with Microsoft SQL Server in the name). If they are enabled, run that line that makes the service dependent and if not, then don't.