Microsoft KB Archive/841713

= BUG: You receive the &quot;service did not respond&quot; error message when you start a Windows service =

Article ID: 841713

Article Last Modified on 5/26/2004

-

APPLIES TO


 * Microsoft .NET Framework 1.0

-



SYMPTOMS
When you try to start a Microsoft Windows service that is built on Microsoft .NET Framework 1.0 and whose AutoLog property is set to True, the Windows service may stop responding if the custom event log is full. Additionally, you may receive the following error message:

Could not start the  service on Local Computer.

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

The  is the Windows service that you created by using Microsoft .NET Framework 1.0.



CAUSE
When the Windows service starts, the ServiceBase class writes the event to the custom event log. If the custom event log is full, the ServiceBase class tries to write the response to the custom event log when the OnStart method is called. Because the custom event log is full, the OnStart method cannot write the response to the custom event log file, and the ServiceBase class stops responding. Therefore, the Windows service indicates that the status is Starting.



RESOLUTION
To resolve this problem, set the AutoLog property of the Windows service to False.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the problem
To reproduce this problem, follow these steps. These steps are described in detail later in this section.
 * 1) Create a Windows service by using Microsoft Visual Studio .NET.
 * 2) Create and attach a custom event log to the Windows service.
 * 3) Add a service installer to the Windows service that you created earlier.
 * 4) Add a setup project to the new service solution.
 * 5) Deploy the Windows service.
 * 6) Set the event log property.
 * 7) Start and stop the service.

Note You can reproduce this problem only on the computer that is running Microsoft .NET Framework 1.0.

To reproduce the problem, follow these steps:  Create a Windows service by using Microsoft Visual Studio .NET:  Start Visual Studio .NET. On the File menu, point to New, and then click Project. The New Project dialog box appears. Under Project Types, click Visual C# Projects. Under Templates, click Windows Service. Type New Service in the Name box, and then click OK.</li></ol> </li> Create and attach a custom event log to the Windows service: <ol style="list-style-type: lower-alpha;"> On the View menu, click Toolbox.</li> In the toolbox, add an EventLog component. By default, the EventLog1 is created and is added to the design mode.</li> Click the design view of the Service1 service, and then press F4. The Properties window appears.</li> Set both the CanPauseAndContinue property and the CanShutdown property to True .</li> In Solution Explorer, right-click the Service1.cs file, and then click View Code.</li>  In Service1.cs file, locate the following code: public Service1 {           // This call is required by the Windows.Forms component designer. InitializeComponent; Add the following code after the previous code: if(!System.Diagnostics.EventLog.SourceExists(&quot;MyLogSource&quot;)) {               System.Diagnostics.EventLog.CreateEventSource(&quot;MyLogSource&quot;, &quot;MyLog&quot;); }           eventLog1.Source = &quot;MyLogSource&quot;; eventLog1.Log = &quot;MyLog&quot;; </li>  In the Service1.cs file, locate the following code: protected override void OnStart(string[] args) { Add the following code after the previous code: eventLog1.WriteEntry(&quot;My Service Has Been Started&quot;); </li>  In the Service1.cs file, locate the following code: protected override void OnStop { Add the following code after the previous code: eventLog1.WriteEntry(&quot;My Service Has Been Stopped&quot;); </li> On the File menu, click Save Service1.cs to save the file.</li> In Solution Explorer, right-click New Service, and then click Properties. The New Service Property Pages dialog box appears.</li> In the Application section, select New_Service.Service1 from the box that is next to Startup Object, and then click OK.</li> On the Build menu, click Build Solution.</li></ol> </li> Add a service installer to the Windows service that you created earlier: <ol style="list-style-type: lower-alpha;"> After the Build Solution process is completed, right-click Service1.cs in Solution Explorer, and then click View Designer. The Service1.cs [Design] page appears.</li> <li>On the View menu, click Properties Window. The Properties window appears.</li> <li>Click the Add Installer link at the bottom of the Properties window. The serviceProcessInstaller1 component and the serviceInstaller1 component are added to the Project Installer.cs [Design] page.</li> <li>On the Project Installer.cs [Design] page, click serviceProcessInstaller1, and then press F4. The Properties window appears.</li> <li>Set the Account property to LocalSystem.</li> <li>On the Project Installer.cs [Design] page, click serviceInstaller 1, and then press F4. The Properties window appears.</li> <li>Set the StartType property to Automatic.</li></ol> </li> <li>Add a setup project to the new service solution: <ol style="list-style-type: lower-alpha;"> <li>On the File menu, point to Add Project, and then click New Project. The Add New Project dialog box appears.</li> <li>Under Project Types, click Setup and Deployment Projects.</li> <li>Under Templates, click Setup Project, type MySetup1 in the Name box, and then click OK. The File System  page appears.

Note is a placeholder for the name of the setup project that you want to create.</li> <li>Under File System on Target Machine, right-click Application Folder, point to Add, and then click Project Output. The Add Project Output Group dialog box appears.</li> <li>Click Primary output, and then click OK to close the dialog box.</li> <li>In Solution Explorer, right-click  , point to View, and then click Custom Actions. The Custom Actions  editor appears.</li> <li>In the Custom Actions  editor page, right-click Custom Actions, and then click Add Custom Action. The Select Item in Project dialog box appears.</li> <li>Double-click Application Folder, click Primary output from NewService (Active), and then click OK.</li> <li>On the Build menu, click Build .</li></ol> </li> <li>Deploy the Windows service: <ol style="list-style-type: lower-alpha;"> <li>Locate the debug folder of the  project. Double-click  .msi. The   dialog box appears.</li> <li>Click Next.</li> <li>On the Select Installation Folder page, click Everyone, and then click Next.</li> <li>On the Confirm Installation page, click Next. The Installing  page appears.</li> <li>After the installation is completed, the Installation Complete page appears. Click Close to close the   dialog box.</li></ol> </li> <li>Set the event log property: <ol style="list-style-type: lower-alpha;"> <li>Click Start, click Run, type services.msc in the Open box, and then click OK. The Services window appears.</li> <li>Locate the Service1 service, right-click Service1 service, and then click Properties. The Service1 Properties (Local Computer) dialog box appears.</li> <li>Click Start to start the Service1.</li> <li>Click Start, click Run, type eventvwr in the Open box, and then click OK. The Event Viewer window appears.</li> <li>In the left pane of the Event Viewer window, right-click MyLog, and then click Properties. The MyLog Properties dialog box appears.</li> <li>Under Log size, set Maximum log size to 64 kilobytes (KB), and then click Do not overwrite events (clear log manually).</li> <li>Click OK, and then close Event Viewer.</li></ol> </li> <li>Start and stop the service: <ol style="list-style-type: lower-alpha;"> <li>Click Start, click Run, type services.msc in the Open box, and then click OK. The Services window appears.</li> <li>Locate the Service1 service, right-click the Service1 service, and then click Properties. The Service1 Properties (Local Computer) dialog box appears.</li> <li>Fill the MyLog log file so that it is larger than 64 KB. To do this, manually start and stop the service repeatedly. As soon as the MyLog file is full, try to start the service.

You receive the error message that is mentioned in the &quot;Symptoms&quot; section.</li></ol> </li></ol>

<div class="references_section">