error when starting a windows service created in c#.net
Hello,
* I have developed a sevice in c#.net.
*I installed it using a setup file created through visual studio 08.
*My service is also visible in local services in control panel.
*But when i start my service there is an error .The error no is 1053 stating:The service did not respond to start or control request in a timely fashion.
*Aftr this error the status of the service is 'starting' n i can neither start,stop,pause etc...
* i added "thread.sleep(40000)" in the onstart n onpause event.
* i even dont know to debug the service.
* Could ne one plz help me to solve this problem...its very important and urgent...
*plz reply in detail and clearly as iam a junior .net developer..and need a clear idea to understand and implement..
* do u require my code??
*Plz do reply..
Mumtaz Surani
Mumtaz SuraniPosted Jul 29, 2009, 4:22 AM
thanks 4 responding..ya ill show u the code in onstart event...but i would like to inform that my that error is solved...the problem was in code of application in onstart event...but thats not over ..i need ur help as there is another problem as described below..
*When i start the service from local services..a message comes stating.."The service started and stopped automatically.some services stop automatically if they have no work to do"....
*I searched and tried solving it ...by clearing eventlog and some other options ..but in vain...
CODE AT ONSTART:
protected override void OnStart(string[] args)
{
string m;
try
{
MessageQueue mq = new MessageQueue(@".\Private$\MyQueue");
System.Messaging.Message mes = mq.Receive(new TimeSpan(0, 0, 3));
mes.Formatter = new XmlMessageFormatter(new string[] { "System.String,mscorlib" });
m = mes.Body.ToString();
}
catch
{
m = "No Message";
}
MessageBox.Show("MyService started");
MessageBox.Show(m);
eventLog1.WriteEntry("my service started");
}
EXPLANATION:...the try catch block has the actual code which i want to run as a service..
*it just retrieves messages from mesage queue(msmq)...and if msmq is empty displays "no msg"...in a msgbox.
*why is this happening...and wanted to say that the actual code is right and displays proper output in a different form also..
*Do reply as fast as possible...waiting 4 answer
bharathPosted Jul 29, 2009, 1:22 AM
Please send the code written in OnStart event.
Are you accessing any entry from web.config in OnStart event?
Debugging we will discuss later once the error is resolved.
Thanks,
Bharath S
Hello,
* I have developed a sevice in c#.net.
*I installed it using a setup file created through visual studio 08.
*My service is also visible in local services in control panel.
*But when i start my service there is an error .The error no is 1053 stating:The service did not respond to start or control request in a timely fashion.
*Aftr this error the status of the service is 'starting' n i can neither start,stop,pause etc...
* i added "thread.sleep(40000)" in the onstart n onpause event.
* i even dont know to debug the service.
* Could ne one plz help me to solve this problem...its very important and urgent...
*plz reply in detail and clearly as iam a junior .net developer..and need a clear idea to understand and implement..
* do u require my code??
*Plz do reply..