I have a csharp app running in my customer's server. The app is a Windows Service.
I want to be able to tell if app is running, if it is stopped and lastly I want to be able to restart it. Everthing must be done from a web client app.
Because access from external networks to this machine is restricted by my customer, I was thinking about implementing an "Agent Client", which will be just another Windows Service running locally and that could execute the "restart" and "stop" commands. It would be pulling an external "Agent Server" to find out if commands need to be executed.
What do you think about this? Any better ideas?
Thanks a lot!
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.
Im looking at creating a service on a remote server that a win forms app can communicate with. (Where the forms app is running locally on user machines).
The service can either run in IIS (7.5) or as a windows service, but essentially I need to be able to call the service from the forms app and then have a stream of progress sent back to the forms app from the service, much like you would output to a Console window.
I've looked into using WCF which seems ideal except I couldn't find out whether I can relay progress updates back to the forms app. Also SignalR running as a self hosted windows service seems to be an option but might be overkill?
We'll be running the forms app on win7 and the remote server will be running server 2008.
Are you able to advise best routes to go down for this and if possible some examples or tutorial links?
Many thanks :-)
If you are looking for the application to relay back to the server for progress, seems you are looking for something like this:
WCF Duplex
It basicly enable you to call bi-directional function using open socket.
Hope it helps.
Thanks,
Amir
Are there situations that we should use a windows service ?
I am building a client-server project (c#) and the server supposed to work alone without any user so someone advised me to use a windows service to run the server, is this right ? or there are a better solutions ?
Windows services are normally used when an application needs to continuously run. For example if they need to:
Wait for incoming requests. (Like through remoting or wcf)
Monitor a queue, file system etc.
If a program just needs to run periodically, like once a day. It is normally easier to create a scheduled task.
In your situation I would use a service for the following reasons:
You don't need to have a session running. This is good for security, and also reduces overhead on the server.
You get some of the managment commands built in for free
Start
Stop
Pause
Continue
You can handle server events such as shutdown.
Windows service can start running as soon as the machine is powered up, which makes ideal for running as a server, http server for example. No one is required to login.
You should create a Windows Service to run code in the background, without user interaction.
For example, a Windows Service will run even if no-one is logged on.
Any server that accepts connections (such as a mail, web, or FTP server) should usually be a Windows Service.
Well, a Windows Service provides a full framework for your application to work and to remain active while you want it to, so I think its ok.
Windows services are the right thing to use for something that should run all of the time, whether or not a user is logged in.
If you need something to run without an active user logged in, you need to use a windows service.
When you need the application to start running even when no one has physically logged into the machine, which is common with server machines, a service is a good candidate in this case. Especially because the service can be configured to auto start, which means the service will start when the machine is rebooted withut human intervention.
If however you are wanting to host web services (WCF) while a service is an option, you might consider hosting in IIS, this relieves you of writing the actual hosting code etc.
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.