Click to See Complete Forum and Search --> : error stop a Windows service
George2
May 30th, 2008, 03:44 AM
Hello everyone,
Here is my OnStop method of Windows service application. When click stop, the error message is, "Error: 1067 The process terminated unexpectedly".
I have tested if remove the Join method, the service can stop gracefully. Does it mean Join method is not allowed to be called in OnStop method of a Windows service? Any ideas?
protected override void OnStop()
{
MyWorkerThread.Join();
this.ExitCode = 0;
}
thanks in advance,
George
Arjay
May 30th, 2008, 12:27 PM
Are there any errors reported in the event log? If so, what are they?
In a general sense, the OnStop method is like the OnStart method in that anything done within these messages needs to be completed within a reasonable amount of time (what ever the OnStart/OnStart timeout is).
If it these methods don't finish in a timely manner, the SCM (service control manager) will terminate the service.
To understand what I mean, just put a Sleep( 50000 ); in the OnStart method and start the service with the service applet.
That being said, could the Join in the OnStop method be preventing this method from completing?
George2
May 31st, 2008, 07:25 AM
Thanks Arjay,
I found when using administrator account to run the service, everything is fine. So I think it may be the issue of using NT AUTHORITY\Network Service account, which is not granted enough privilege.
Now I am going to try to reproduce this issue, my current question is, when assign the log-on account back to NT AUTHORITY\Network Service, and clicks ok in SCM, there is an error message which indicates me to input a correct password for NT AUTHORITY\Network Service.
But I do not know the password for this account. And I want to reset the password for NT AUTHORITY\Network Service.
How to reset the password for this account? Normally to any other account in the Windows server 2003? I have this question is because I noticed a couple of the Windows Services on my local computer is using this account to log on, I do not want to impact other services when changing the password for account NT AUTHORITY\Network Service.
Any comments?
Are there any errors reported in the event log? If so, what are they?
In a general sense, the OnStop method is like the OnStart method in that anything done within these messages needs to be completed within a reasonable amount of time (what ever the OnStart/OnStart timeout is).
If it these methods don't finish in a timely manner, the SCM (service control manager) will terminate the service.
To understand what I mean, just put a Sleep( 50000 ); in the OnStart method and start the service with the service applet.
That being said, could the Join in the OnStop method be preventing this method from completing?
regards,
George
Arjay
May 31st, 2008, 01:58 PM
If I understand correctly, the system assigns the network service password.
I assume you created an installer for your service and have set it up to use the Network service as the logon.
If so, I would uninstall the service (using InstallUtil.exe) and then re-install the service.
When you install the service, the proper network service pw will be used.
Btw, due to the permissions issue, you may have to run the service under a different account.
George2
June 1st, 2008, 04:32 AM
Thanks Arjay,
I have fixed this issue in another way. I have tried there is no password for Networkservice account. I set the password for null and the issue can be reproduced. :-)
If I understand correctly, the system assigns the network service password.
I assume you created an installer for your service and have set it up to use the Network service as the logon.
If so, I would uninstall the service (using InstallUtil.exe) and then re-install the service.
When you install the service, the proper network service pw will be used.
Btw, due to the permissions issue, you may have to run the service under a different account.
regards,
George
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.