[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2882
  • Last Modified:

Error 1053: The service did not respond to the start or control request in a timely fashion

I have written a windows service in C++ that has so far installed and ran well on all the machines I have tested it on.  However, I tried installing it on a couple Windows XP prof machines all running SP2 and all with the .NET framework 1.1 with sp 1 and I got the error posted above.  I have looked at the msdn and all I could find was them telling me that I had to put .NET 1.1 sp1 on the machine to resolve the problem.  I did this and it did not resolve the problem.

This is a very urgent and important problem for me  If I could I would easily put down 1000 points or more.  Any information on how to reoslve this problem for real will be very greatly appreciated.

Thanks,

PT
0
ptrennum
Asked:
ptrennum
  • 12
  • 6
  • 4
  • +4
2 Solutions
 
AxterCommented:
Hi ptrennum,
Can you start up your service after you logon?
Does your service have any dependencies on other services?
If so, do you have your service setup with those dependencies?


David Maisonave :-)
Cheers!
0
 
ptrennumAuthor Commented:
I can not start the service at any point on the problem machines.  On other machines I can start it at anytime.  THe service is not dependent on any other services.  THe service itself simply takes a bunch of files zips them up and sends them using http sockets to a specified IP and port.
0
 
AxterCommented:
>>using http sockets to a specified IP and port.
FYI:
If it uses sockets, then it is depenent on other services.
However, since you said you can not start it at any point, then this is not the issue.

I recommend you try adding debug code in your application that logs it's progress, so you can pin point the problem.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ptrennumAuthor Commented:
what other services is it dependent on if it is using http sockets - I wasn't sure thats why I stated I was using them.

THanks

PT
0
 
AxterCommented:
>>what other services is it dependent on if it is using http sockets
I believe it's [Network Connections]

The easiest way to make sure you have all the services requried for http, is to make your services depedent on [Remote Procedure Call (RPC)]

However, this shouldn't have anything to do with your current problem, since you said you can't start it at any time.
0
 
r-kCommented:
Might there be something in the Event Logs to give you a hint about your problem?
0
 
grg99Commented:
If you have SP2 then the firewall may be blocking your network connections.  Go intothe security center control panel and set your ports as exceptions.

0
 
ptrennumAuthor Commented:
I have disabled all firewalls - but good suggestion

PT
0
 
jkrCommented:
Can you put debugging code in you 'ServiceControl()' handler to see what control requests are being sent and cross-check which your service handles?
0
 
mactep13Commented:
Check your service app for security permissions. Make sure that the account that is starting the sercvice is actually authorized to run the executable. Sometimes, you need to specify a check box in the Allowed box for full access in order for the service to run. If the security is not an option, I would suggest setting Everyone to have Full Control allowed.  Test it out. If the service starts with Everyone permissions set to full control, then it is definetly a permissions issue.

Hope this helps,

Mactep.
0
 
Julian HansenCommented:
During initialisation of your service are you posting messages to the Service Control Manager by means of the SetServiceStatus? Just a thought that the XP SCM might be a little more intollerant of services that don't report their status in a timely fashion.
0
 
ptrennumAuthor Commented:
The service posts the same error on every computer I have tried it on that does not have VS.NET installed on it.

PT
0
 
ptrennumAuthor Commented:
THe service runs as a system process so permissions should not be a problem.

PT
0
 
jkrCommented:
Have you tried to add the debugging code to the control handler to see *which* request times out? E.g.

void WINAPI MySvcCtrlHandler ( DWORD dwControl) {

    char acCtrlMsg[255];
    wsprintf(acCtrlMsg, "Service MySvc received control request %d\n", dwControl);
    OutputDebugString(acCtrlMsg);

    // ....
}

?
0
 
ptrennumAuthor Commented:
The Service has no dependencies as far as I can see, This is from checking under the properties of the service and then the dependencies tab.

PT
0
 
Julian HansenCommented:
Have you run the depends.exe on the service to see what DLL's it requires?

I had a similar problem with another app (not a service) the target machine was missing the Visual Studio .Net redistributables for C/C++

In particular

msvcr71.dll

Depends.exe will tell you what DLL's the service is dependent on - you might find the machines in question are missing these.

0
 
ptrennumAuthor Commented:
This is what my service contrl handler looks like,  THe file ass is never created and no entries are logged about the fdwControl.  THe strange thing is that this is done on a computer that does allow the service to start.

VOID WINAPI ServiceCntrlHandler(DWORD fdwControl)
{
      
      DWORD nBytes;
      ass = CreateFile("C:\\ShacoOnlineBackup\\Logs\\Control.ass", GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL);

      char acCtrlMsg[255];
    wsprintf(acCtrlMsg, "Service MySvc received control request %d\n", fdwControl);
    WriteFile(ass,acCtrlMsg,255,&nBytes,NULL);

      SERVICE_STATUS SrvcStatusInfo;

      switch(fdwControl)
      {
/*            case SERVICE_CONTROL_STOP:
                  break;
            case SERVICE_CONTROL_PAUSE:
                  break;
            case SERVICE_CONTROL_CONTINUE:
                  break;
            case SERVICE_CONTROL_INTERROGATE:
                  break;
            case SERVICE_CONTROL_SHUTDOWN:
                  break;*/
      }

      SrvcStatusInfo.dwServiceType=SERVICE_WIN32_OWN_PROCESS;
      SrvcStatusInfo.dwCurrentState=SERVICE_RUNNING;
      SrvcStatusInfo.dwControlsAccepted=NULL;
      SrvcStatusInfo.dwWin32ExitCode=NO_ERROR;
      SrvcStatusInfo.dwServiceSpecificExitCode=0;
      SrvcStatusInfo.dwCheckPoint=0;
      SrvcStatusInfo.dwWaitHint=0;
      SetServiceStatus(hSrvcStatus, &SrvcStatusInfo);
      WriteFile(ass,"testestest",10,&nBytes,NULL);
}
0
 
jkrCommented:
>> This is what my service contrl handler looks like

Yes, but that does not help to identify which request times out...
0
 
ptrennumAuthor Commented:
I just ran it through depends.exe which was a great idea but I don't really have any idea what I'm looking at here.

PT
0
 
ptrennumAuthor Commented:
>> >>This is what my service contrl handler looks like

Wouldn't the calls to WriteFile write the requests to the file??

PT
0
 
jkrCommented:
>>Wouldn't the calls to WriteFile write the requests to the file??

Yes, but:

CREATE_ALWAYS Creates a new file. If the file exists, the function overwrites the file and clears the existing attributes.

That means you're always overwriting it... I'd rather recommend using 'OutputDebugString()' and 'DebugView' (http://www.sysinternals.com/ntw2k/freeware/debugview.shtml). Anyway, what are the results?
0
 
Julian HansenCommented:
dependecies - you are looking for DLL names that might not exist on the target machine.

In the top left window of Depends will be a tree of dll file names. For each dll off the root node there will be a sub-tree of dependencies that dll is reliant on. For this exercise you are only interested in those entries under the root i.e.

- SERVICE.EXE
  + MFC71.DLL
  + MSVCR71.DLL
  + KERNEL32.DLL
  + USER32.DLL
  + ADVAPI32.DLL
  + COMCTL32.DLL
  + OLE32.DLL
  + OLEAUT32.DLL
  etc

Most of these should be on the workstation. However, you mentioned that this seems to be related to the presence or absence of VS .Net 1.1 framework in order to work. Question - are you using managed code? If not then it is probable that the only components of the .Net framework you need are the updated VS .Net runtime libraries. For release builds these would be

MFC71.DLL
MSVCR71.DLL

Check the dependencies and post them back here if you are uncertain - look for corresponding dll's on the machines where the code does not work.
0
 
ptrennumAuthor Commented:
Nothing is written to the file or when I open debug view then start the service after adding in the OtputDebugString() nothing appears in the debugView window either, I am testing this on a machine that runs the service successfully as well.

PT
0
 
ptrennumAuthor Commented:
MFC71.DLL
MSVCR71.DLL


Both of those DLLs are on machiens where the service does not run.

Here's the depends root:

SHACOSERVICE.EXE
-KERNEL32.DLL
-USER32.DLL
-ADVAPI32.DLL
-COMCTL32.DLL
-SHLWAPI.DLL
-MFC71D.DLL
-MSVCR71D.DLL
-WS2_32.DLL
-OLEACC.DLL
-GDI32.DLL
-WINSPOOL.DRV
-COMDLG32.DLL
-SHELL32.DLL
-OLE32.DLL
-OLEAUT32.DLL

PT
0
 
Julian HansenCommented:
I have just posted some code to our website in response to another query.

http://www.managedprofile.com/downloads/simplesvc2.zip

This is a simple service that writes to a log file every 5 seconds. You could try this service on both machines that work and those that don't and see if it also fails - if it does - it is most likely a dependency error - else try to match the code to what you are doing in your app to see if it helps.

To compile and test
 create an empty console project and add the .cpp file in the zip.
Compile.
Run with the -install command line param to install then proceed as normal with a service
0
 
jkrCommented:
>>Both of those DLLs are on machiens where the service does not run.

Hmm, DLL dependencies and Control Request Timeouts seem quite unrelated to me... So, what requests are being sent to your service? The one that times out should be the last one you see in the output.
0
 
jkrCommented:
... sorry, that is, if the service does not start at all, it could well be a dependency issue, but a different error message.
0
 
ptrennumAuthor Commented:
!!!!FIXED IT!!!!!!

I was missing these dll's - This is such a huge releif!!

Thank you all so much that have helped and posted back in such a timely fashion!

-MFC71D.DLL
-MSVCR71D.DLL

THanks again You're all great!!


PT
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 12
  • 6
  • 4
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now