473,671 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Starting a service error.

46 New Member
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 3368
PRR
750 Recognized Expert Contributor
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
rottmanj
46 New Member
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 Recognized Expert Contributor
@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 Recognized Expert Expert
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
3358
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 start the Service from Administrative Tools services, it shows starting and after sometime throw error that the service does not respond in time and the ststus is shown as "starting". However during this time, the BisObject is doing its job and...
1
1777
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 account and the Interact with the Desktop is Checked. Windows media player seems to start but then closes almost immediately. I would appreciate any help. Thanks, Glenn
2
1882
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 (exceptions) to the monitor thread. Of course, all works well on my box. Yesterday I installed the .NET Framework 1.1 on a new server and then installed my service. It appears that everything is starting but when I perform a netstat - a...
2
2227
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 *sometimes* crashes upon starting. The progressbar you get when you manually start the server will very slowly progress, and when it hits 100% after 2 minutes or something I get the error 'The service could not be started because it did not...
0
2801
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 progress fine until it hits about halfway. It then stops there for about 4 or 5 seconds then goes a little farther. I then get a message: Could not start the MyService Service on Local Computer. Error 1053: The service did not respond to the...
6
4178
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 time, but occasionally after a system startup (where the service doing the starting of the other is automatically started by Windows XP) the ServiceController's Start() method fails to start the other service. It is probably throwing an...
3
4129
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 will try and stop a service that is disabled and will display msg "Error stopping service." if i run script on a service that is already running, it stop then start the service and restarts it again. Thanks whoever has the time to help me. Option...
7
1760
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 this polling loop is entered synchronously from OnStart, basically the OnStart event doesn't terminate for the life of the program. This doesn't give the SCM the correct feedback that the service has started properly. Consequently, the SCM throws...
5
4715
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 more, but I couldn't get it working, so I boiled it down to the exception to test. Anyway, the service can be installed using InstalUtil but when starting the service, I just get the message that the service stopped again withour reporting any...
0
8483
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8927
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8825
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8605
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.