BUG: You receive the "service did not respond" error message when you start a Windows service (841713)



The information in this article 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 Name service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion.
The Service Name 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 "Applies to" section.

MORE INFORMATION

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:
  1. Create a Windows service by using Microsoft Visual Studio .NET:
    1. Start Visual Studio .NET.
    2. On the File menu, point to New, and then click Project. The New Project dialog box appears.
    3. Under Project Types, click Visual C# Projects.
    4. Under Templates, click Windows Service.
    5. Type New Service in the Name box, and then click OK.
  2. Create and attach a custom event log to the Windows service:
    1. On the View menu, click Toolbox.
    2. In the toolbox, add an EventLog component. By default, the EventLog1 is created and is added to the design mode.
    3. Click the design view of the Service1 service, and then press F4. The Properties window appears.
    4. Set both the CanPauseAndContinue property and the CanShutdown property to True.
    5. In Solution Explorer, right-click the Service1.cs file, and then click View Code.
    6. 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("MyLogSource"))
      			{
      				System.Diagnostics.EventLog.CreateEventSource("MyLogSource", "MyLog");
      			}
      			eventLog1.Source = "MyLogSource";
      			eventLog1.Log = "MyLog";
      
    7. 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("My Service Has Been Started");
    8. In the Service1.cs file, locate the following code:
      protected override void OnStop()
      		{
      Add the following code after the previous code:
      eventLog1.WriteEntry("My Service Has Been Stopped");
    9. On the File menu, click Save Service1.cs to save the file.
    10. In Solution Explorer, right-click New Service, and then click Properties. The New Service Property Pages dialog box appears.
    11. In the Application section, select New_Service.Service1 from the box that is next to Startup Object, and then click OK.
    12. On the Build menu, click Build Solution.
  3. Add a service installer to the Windows service that you created earlier:
    1. 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.
    2. On the View menu, click Properties Window. The Properties window appears.
    3. 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.
    4. On the Project Installer.cs [Design] page, click serviceProcessInstaller1, and then press F4. The Properties window appears.
    5. Set the Account property to LocalSystem.
    6. On the Project Installer.cs [Design] page, click serviceInstaller 1, and then press F4. The Properties window appears.
    7. Set the StartType property to Automatic.
  4. Add a setup project to the new service solution:
    1. On the File menu, point to Add Project, and then click New Project. The Add New Project dialog box appears.
    2. Under Project Types, click Setup and Deployment Projects.
    3. Under Templates, click Setup Project, type MySetup1 in the Name box, and then click OK. The File System (MySetup1) page appears.

      NoteMySetup1 is a placeholder for the name of the setup project that you want to create.
    4. 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.
    5. Click Primary output, and then click OK to close the dialog box.
    6. In Solution Explorer, right-click MySetup1, point to View, and then click Custom Actions. The Custom Actions (MySetup1) editor appears.
    7. In the Custom Actions (MySetup1) editor page, right-click Custom Actions, and then click Add Custom Action. The Select Item in Project dialog box appears.
    8. Double-click Application Folder, click Primary output from NewService (Active), and then click OK.
    9. On the Build menu, click Build MySetup1.
  5. Deploy the Windows service:
    1. Locate the debug folder of the MySetup1 project. Double-click MySetup1.msi. The MySetup1 dialog box appears.
    2. Click Next.
    3. On the Select Installation Folder page, click Everyone, and then click Next.
    4. On the Confirm Installation page, click Next. The Installing MySetup1 page appears.
    5. After the installation is completed, the Installation Complete page appears. Click Close to close the MySetup1 dialog box.
  6. Set the event log property:
    1. Click Start, click Run, type services.msc in the Open box, and then click OK. The Services window appears.
    2. Locate the Service1 service, right-click Service1 service, and then click Properties. The Service1 Properties (Local Computer) dialog box appears.
    3. Click Start to start the Service1.
    4. Click Start, click Run, type eventvwr in the Open box, and then click OK. The Event Viewer window appears.
    5. In the left pane of the Event Viewer window, right-click MyLog, and then click Properties. The MyLog Properties dialog box appears.
    6. Under Log size, set Maximum log size to 64 kilobytes (KB), and then click Do not overwrite events (clear log manually).
    7. Click OK, and then close Event Viewer.
  7. Start and stop the service:
    1. Click Start, click Run, type services.msc in the Open box, and then click OK. The Services window appears.
    2. Locate the Service1 service, right-click the Service1 service, and then click Properties. The Service1 Properties (Local Computer) dialog box appears.
    3. 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 "Symptoms" section.

REFERENCES

For more information, visit the following MSDN Web site: For additional information about how to create a Setup project, click the following article numbers to view the articles in the Microsoft Knowledge Base:

317421 How to create a Setup project for a Windows service in Visual Basic .NET

816169 How to create a Setup project for a Windows service application in Visual C# .NET


Modification Type:MajorLast Reviewed:5/26/2004
Keywords:kberrmsg kbSCM kbService kbEventLog kbbug KB841713 kbAudDeveloper