Click here to Skip to main content
15,885,885 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all i am start the windows service . but it showing this issue...Please help me.The TestService service on Local Computer started and then stoped. Some service stop automatically if they are not in use by other service or programs
Posted
Comments
Orcun Iyigun 27-Mar-13 3:09am    
You will have generic answers to your question. You have to let us know what you are trying to do maybe provide some code. Have yo debugged your code in the first place? Put your code in try catch block see what exception you are getting. You can also write the exception to your event log and see the details. You can use Debugger.Break(); for this debugging your code..

1 solution

Ok, just solved the same issue, the server started and stopped straight away if there any errors. Debug you service accurately, you can use attached process or build testing system. I usually use simple text logger:

C#
class TextLogger
    {
        public static void Log(LogType logType,string className, string message)
        {
            using (var w = File.AppendText(@"c:\temp\log.csv"))
            {
                var sb = new StringBuilder();
                sb.Append(DateTime.Now);
                sb.Append(",");
                sb.Append(logType.ToString());
                sb.Append(",");
                sb.Append(className);
                sb.Append(",");
                sb.Append(message);
                w.WriteLine(sb);
            }
        }
    }

    enum LogType
    {
        Error
        Action
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900