| | |
Problem with Windows Service
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2006
Posts: 4
Reputation:
Solved Threads: 0
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?
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?
•
•
Join Date: Nov 2006
Posts: 1
Reputation:
Solved Threads: 0
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 add the line . So your method looks like
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
Tatsky
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
c# Syntax (Toggle Plain Text)
static void Main(){}
c# Syntax (Toggle Plain Text)
System.Diagnostics.Debugger.Launch();
c# Syntax (Toggle Plain Text)
static void Main() { System.Diagnostics.Debugger.Launch(); ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new MyService1() }; ServiceBase.Run(ServicesToRun); }
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
Tatsky
![]() |
Similar Threads
- Windows service and threads and sockets (C#)
- Problem accessing Windows Share (Networking Hardware Configuration)
- Windows Service Problem (C#)
- Windows XP Service Pack 2 (Windows NT / 2000 / XP)
- windows service pack 2 installation - unique problem (Windows NT / 2000 / XP)
- Problem installing windows 2000 professional (Windows NT / 2000 / XP)
- Problem Installing Windows XP PRO (Windows NT / 2000 / XP)
Other Threads in the C# Forum
- Previous Thread: HOWTO: Run a Query on a Database using ODBC and return all Results into a DGV Object
- Next Thread: final year proj in .net using c#
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array bitmap box broadcast buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ httpwebrequest image index install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation visualstudio webbrowser windows winforms wpf xml





