Problem with Windows Service Project
Posted on 2006-11-16
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…"
Strange... 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 help?