Hello, I’m hoping someone at MS can help me.

I’ve created a C# Windows Service project whose service main function instantiates a class library that spawns a new thread to create a new process with which to launch osk.exe (the Windows on-screen keyboard). The purpose for creating this service is to have the on-screen keyboard appear immediately after startup (before the login screen) on a system that will have no keyboard hardware.

I had first built a test program (C# console application) to call the class library and test its functionality and it worked fine. Then I created the Service Project including its installer classes and installed the service with installutil. [Incidentally, all three projects—the class library that launches the osk in a new thread, the test console application, and the windows service—are in the same solution.]

Each time I manually start the service (using the MMC snap-in) I get the following message:
" The service <name> on Local Computer started and then stopped. Some services stop automatically if they have no work to do…"

I don’t understand what this means. The class library contains the necessary start and stop methods, and I copied the same code from the test program to the OnStart () method of the service class. Can anyone please help?

Hi There

I have experienced this issue with services that have thrown an exception during the Start() sequence of the Process.

To find out what is causing your service to bomb out, you need to debug the service. Are you using VS to build the service? If so you need to attach to the service thread when it starts, in order to step through the process.

The problem here being that there is no thread to attach to until the service has started, and your service is not getting started. The solution is as follows.

In your method

static void Main(){}

add the line


. So your method looks like

static void Main()
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] { new MyService1() };

Then simply build and install your service. Then goto Service Manager and start the service. You should then see a diaogue pop up asking you what application you would like to use to debug the service. Select your VS which with the Service project open, and VS will then allow you to step through the service. You can then step through the OnStart method and see what is causing you the problem

Let me know if that helps


Thank you for that tip!

It turns out that my service was having trouble finding an associated dll. But had I known you could launch the debugger from within the main function, it might have been easier to resolve.

Thanks again.