473,396 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Starting a service error.

I have written an application that installs a service and then is supposed to start the service. Everything works great except for the service starting(either with AfterIntall or starting it from the window service manager).

The error I get is
Expand|Select|Wrap|Line Numbers
  1. System.InvalidOperationException: Cannot start service qbLinxService on computer ',', ------> System.ComponentModel.Win32Exception: The service did not respond to the start or control request in a timely fashion
  2.  
Now everything I have read thus far states that this is an error only with .net framework 1.1. I am currently running 3.5 on my testing machine. So I am a bit confused as to what is going on.

Here is my service code. Any help with this is greatly appreciated.
Expand|Select|Wrap|Line Numbers
  1. namespace qbLinx
  2. {
  3.     partial class qbLinxService : ServiceBase
  4.     {
  5.         public qbLinxService()
  6.         {
  7.             InitializeComponent();
  8.         }
  9.  
  10.         protected override void OnStart(string[] args)
  11.         {
  12.             //qbConnect qbCnn = new qbConnect();
  13.             //qbCnn.qbTimer();
  14.         }
  15.  
  16.         protected override void OnStop()
  17.         {
  18.             // TODO: Add code here to perform any tear-down necessary to stop your service.
  19.         }
  20.     }
  21. }
  22.  
Dec 23 '08 #1
4 3352
PRR
750 Expert 512MB
If after installation of service (installutil service name ) if you cant start the service from service manager ... i guess the fault may lie in your code... You are tryin to connect to database on start of service?
Expand|Select|Wrap|Line Numbers
  1. qbConnect qbCnn = new qbConnect(); 
  2.  
if yes then maybe it timeouts? you need to take care of exception conditions for windows service..
any code taking more than 60 sec is not recommended for windows service (correct me here if i am wrong )... how abt using asynchronous delegates? Can you post the error message and error code?
Assuming you are tryin to connect to DB ...how can you be sure that DB server is running? and if the DB is on the same machine... your service will have dependency on other service ..
try this
Expand|Select|Wrap|Line Numbers
  1. protected override void OnStart(string[] args)
  2.        {
  3. try{
  4.             //qbConnect qbCnn = new qbConnect();
  5.            //qbCnn.qbTimer();
  6. }
  7.  
  8. catch(Exception e)
  9. {
  10. string error_file = System.Environment.ExpandEnvironmentVariables("%SystemDrive%").ToString() + @"\Error.txt";
  11.  
  12.             using (FileStream fs = new FileStream(error_file, FileMode.OpenOrCreate, FileAccess.Write))
  13.             {
  14.                 using (StreamWriter sw = new StreamWriter(fs))
  15.                 {
  16.                     sw.BaseStream.Seek(0, SeekOrigin.End);
  17.                     sw.WriteLine(e.Message.Tostring());
  18.  
  19.  
  20.                 }
  21.             }
  22.  
  23. }
  24.         }
  25.  
Also i would recommend using good usage of threads in a windows service .. so that it does not block... remember start has to return back as soon as possible...
Dec 24 '08 #2
In the code I posted, I commeted out all actions that should take place with the onstart method. This is what is confusing me, the onstart method is empty of all action and it still fails to start.
Dec 24 '08 #3
PRR
750 Expert 512MB
@rottmanj
well in that case the problem lies elsewhere .... try reinstalling the windows service.. which i m sure you did.... try on another computer, if it works ...then maybe reload OS?
Dec 25 '08 #4
Plater
7,872 Expert 4TB
The error message might be a "best guess" by windows on how to respond.
If your OnStart() does nothing (including not starting any threads) and returns right away, you normally get the message "service started then stopped, this could be do to (blah blah blah)" But maybe if you don't actually call the STOP function, it thinks there is an error starting the service?
Dec 29 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rajesh Abraham | last post by:
I have a Windows Service and in the OnStart, I am initializing the BusinessLayer Object and calling a method of the object, which normally takes about 10 mts to finish execution. Now when I...
1
by: Glenn | last post by:
I have used this code successfully in a form application. I tried to add the same code in a service and have not been able to get the application to start. I have the service starting with a local...
2
by: karl | last post by:
I have a windows service that kicks off a 'monitor' thread which in turn kicks off 4 additional threads. These 4 threads basically are listen on a designated socket and report back any errors...
2
by: Razzie | last post by:
Hey all, I wrote a Windows Service. When I test it on my developement machine (winXP) it works fine. It starts ok, never crashes, etc. When I install the service on another machine (win2000) it...
0
by: tshad | last post by:
I have a Windows Service I created that just sets a timer and writes to EventLog every 10 seconds. It installed fine and it actually starts. But it says it doesn't. The progress bar shows the...
6
by: Arnie | last post by:
We're using the ServiceController class provided by the .NET Framework, programming in C#. We are using the Start() method to start a service from another service. This works fine most of the...
3
by: Cenarius | last post by:
Hi, I need some help, i don't know much about programming other than executing them get getting them from scripting sites. My program is it won't start a service if the startup type is Disabled. it...
7
by: Joseph Geretz | last post by:
I have a Service which runs OK, but I'm abviously not starting it properly. In my OnStart event I commence a long running process which polls a database table and performs various processing. Since...
5
by: eliasen | last post by:
Hi I have created a Windows Service using C# and .NET2.0. The service is quite simple - right now it doesn't do anything except throwing an exception in the OnStart method. It used to something...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.