Windows service failed to start.
-
alright. lemme try and get back to you.
-
yes i put all the code of the Onstart event in try catch block. its no use. i am getting the same error message when i tried to start the service from the service explorer thanks Anil Veeraghattapu.
-
I am creating a windows service using c#.net 3.5 i created installer file to install it. it was installed successfully. when i tried to start the service from the service explorer it showing the below error instead of starting the service "some services stop automatically if they are not in use by other programs or services". Please help me out. Thanks Anil Veeraghattapu.
Have you run it under the debugger yet?
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
yes i put all the code of the Onstart event in try catch block. its no use. i am getting the same error message when i tried to start the service from the service explorer thanks Anil Veeraghattapu.
the problem is : you got an exception in OnStart. You must find the exception, what it is.
try
{
...
}
catch(Exception ex)
{
File.WriteAllText(@"c:\error.txt", ex.ToString());
}If you start the service and got an error, then look at c:\error.txt. That is the error.
-
Have you run it under the debugger yet?
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001the service a'nt got started my friend. i am unable to attach it to debugger. Thanks Anil Veeraghattapu.
-
I am creating a windows service using c#.net 3.5 i created installer file to install it. it was installed successfully. when i tried to start the service from the service explorer it showing the below error instead of starting the service "some services stop automatically if they are not in use by other programs or services". Please help me out. Thanks Anil Veeraghattapu.
In the event log you can see further information, if there's an exception you will be able to see it there as well.
-
yes i put all the code of the Onstart event in try catch block. its no use. i am getting the same error message when i tried to start the service from the service explorer thanks Anil Veeraghattapu.
Anil Veeraghattapu 4 wrote:
i put all the code of the Onstart event
There is your problem. The general layout of a Service is, in OnStart, you are expected to start a seperate thread that handles your main service code loop, such a listeners or some kind of polling loop, ... This releases OnStart and returns control back to the Service Control Manager. In OnStop, you shutdown this loop as appropriate and let the thread stop gracefully. Putting all of your code in OnStart gives you exactly the error message your getting because OnStart never returns control back to the SCM within the default 30 seconds the SCM expects OnStart to return.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
I am creating a windows service using c#.net 3.5 i created installer file to install it. it was installed successfully. when i tried to start the service from the service explorer it showing the below error instead of starting the service "some services stop automatically if they are not in use by other programs or services". Please help me out. Thanks Anil Veeraghattapu.
You can debug services using the AndersonImes.ServiceProcess dll which works really well. Had a quick look but can't find it so you may have to contact[^] him directly: well worth having in your toolkit.
me, me, me "The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!" Larry Niven nils illegitimus carborundum
-
the problem is : you got an exception in OnStart. You must find the exception, what it is.
try
{
...
}
catch(Exception ex)
{
File.WriteAllText(@"c:\error.txt", ex.ToString());
}If you start the service and got an error, then look at c:\error.txt. That is the error.
Thanks i find the exception in the text file. you did a great help. the problem is it was a fromat exception throw by a log control when i tried to log somethin in the on start event Thanks Anil Veeraghattapu.
-
In the event log you can see further information, if there's an exception you will be able to see it there as well.
Yes you are right. it was some format exception i find it in the event log too. Thanks for your help Thanks Anil veeraghattapu.
-
the service a'nt got started my friend. i am unable to attach it to debugger. Thanks Anil Veeraghattapu.
Wrong. Put a breakpoint at the top of the Start)( method.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001