Window Service status it is appearing as running, But not working - c#

I am not quite sure, if I can have an answer to this question but it will be nice to know some suggestions about it.
I have a windows service with two threads. It was working perfectly fine for a time but it seems that it stopped working on last week. When I checked the service status it is appearing as running and startup type is automatic. But service didn't pick the data from service queue. There is no error log and I think thread got stopped, but don't why?

Yes, We found while deployment of Application , there was some dependecy of service on windows, which cause these issue.
We fixed the issue by each time reset the IIS and stop all services and then reinstall them each time.

In our case , we found issue due to incorrect exception handling.
When Installer install the service but in case of any request , which cause any crash while execution, then service is reflected as running state but stop working.

Related

Windows Service Stop working suddenly and work fine after server restart

I have few service developed in .net. they are working fine but some time suddenly stop working and dont run even i restart them. the only solution is to restart the server. Once server restart everything work fine as previous
I would check Windows Event Viewer for a start to maybe get the error being thrown by .NET Framework when the service stops working. If a server restart is required to get it to run again, it probably is something environmental caused by your service.
With the details provided in your question, that's the best I can advise.

C# MVC app on Azure: Site works fine when freshly deployed but fails after being left idle

I have spent a good bit of time researching this but have not found anybody else reporting the issue that I am having.
I deploy my site and everything is good. I share the link with my QA and UI peeps and everything works for them. But if the site goes for a period of time, such as overnight, without being accessed then the web application is unable to start and reports "Method 'get_CurrentUser' in type ... does not have an implementation." Stopping and restarting the site does not resolve the issue but if I simply re-upload the main .dll file (the exact same version of the .dll) to the site then everything works fine again. For a while, at any rate.
Why would it be okay when newly published but fail after sitting for some time? Any suggestions on troubleshooting this would be greatly appreciated.
IIS has introduced Suspend action for idle timeout, when site is idle for specified duration, IIS will suspend process, god knows what happens exactly but looks like it just hibernates the process. And waking up may not work, so you can change this action to terminate for idle timeout.
Second option is to keep site awake by using pingdom or site24x7 services.
Could it help to try Azure Web App and set Always On?
http://azure.microsoft.com/updates/azure-web-sites-adds-always-on/
It looks like I found a solution.
The app start event in global.asax included "var assemblies = System.Web.Compilation.BuildManager.GetReferencedAssemblies();" in order to make sure that everything loads, but that line was -after- the call that was triggering all of the dependency registration. I cut/pasted that line so that it happens first and the site came up fine when I tried it this morning.

The service did not respond to the start or control request in a timely fashion if Debug dll used

I was trying to deploy a windows service on my machine, but when I was trying to start it I got following error.
"Windows could not start the 'myService' on Local Computer. Error 1053: The service did not respond to the start or control request in a timely fashion."
After a bit of research I found out that I was complining my project with Debug option, the moment I changed it to 'Release' mode all was good and working. I can not make sense of this behaviour so I searched the net and found this debug-vs-release-in-net but even this does not explain why my window service was failling to start if i was using debug mode's dll
If anyone can explain it that will help me lot to understand how this actually works thanks.

Service restarts automatically after it is manually stopped

I have created a windows service in C#.NET that is continuously running. Now when i stop it from the services.msc initially it shows that it has been stopped but after some time when i refresh the services.msc it shows as started again. I also checked in the task manager at the same time, i see that the exe of my application gets killed but starts on its own again.
Please help.
If you take a look into the properties of your service, there is a tab called Recovery. Maybe there is something configured on this page which automatically restarts the service.
Maybe you can use Process Monitor to find out a little more about who starts your service?
I suppose this was something to do with the operating system. I deployed my service on Win2k3 and it worked just fine. It started perfectly and stopped when i stopped it from Services.msc. I was trying to deploy the service on WinXP earlier. Please let me know if anyone else has faced such an issue.

Service cannot be started

I developed a simple windows service in C# as per this article.
http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx
I was successfully able to start the service for the first time and stop it. During the following attempts, I was not able to start the service. I got the following information.
The MyNewService service on Local
Computer started and then stopped.
Some services stop automatically if
they have no work to do, for example,
the Performance Logs and Alerts
service.
Please help.
I outlined here a method we're using to debug our Windows services. Maybe this will help you trace the error. Basically this sounds like some error is occurring while trying to execute the OnStart method.
Basically this means the main thread of your service has crashed for some reason. The most common I've seen is filesystem access to it's own log files.
Sometimes you can find the reason in the event viewer, but unfortunately a lot of the time the user you're running the service as won't actually have access to log it's error. A simple thing to do if you're in a dev environment is to just give the service an administrator account temporarily, firstly cause it'll tell you whether the crash is being caused by lack of access (cause it'll work) and secondly if it's not it'll allow it to write to the event viewer. Make sure to take the admin access of f once you fix it though, cause long-term that can be very dangerous.
Did you look in the event log? You can usually get more detailed error information there about the service error. Also, are you writing out to a log with your service? That's another way you could figure out what's going wrong.
You can get to the event log by right clicking on Computer and selecting "Manage". Under System Tools, look under Event Viewer->Application. This is on Windows XP, but other Windows OS's should be similar.
If the service is on your development machine, you should be able get Visual Studio's debugger to attach to it as it starts so that you could identify if anything is causing it to crash. It involves a bit of registry editing as described here: http://blogs.msdn.com/greggm/archive/2005/02/21/377663.aspx
It sounds like your main thread is dying for some reason. Put a call to System.Diagnostics.Debugger.Break() in your service's startup code, e.g., the Main entry point, the service constructor, or the OnStart() method. When you start your service from the Services MMC, you'll be prompted to enter a debug session. Once you're in Visual Studio, open the Exceptions dialog (from the Debug menu) and check the boxes in the Thrown column. Then debug from there to find the problem.

Categories

Resources