windows-services

Communication between different C# based services

淺唱寂寞╮ 提交于 2019-12-05 18:46:29
Is there a way to communicate between two different services? I have a service that already runs. Is there a way to create a second service that can attach to the first service and send and receive dates to it? I would also like to access the Windows service from a console application and attach to it. Is it possible? James Kyburz To begin with I would play around with tcpclient and tcpserver http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.aspx http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx Even if the data you need to send is more complex than

Writing a Scheduled Windows Service in .NET

为君一笑 提交于 2019-12-05 18:39:40
I want to write a windows service which the user can schedule. i.e, the user can choose to run the service from 9:00 AM to 6 PM daily, or he could run it every night, starting from night 12 o clock at night to next day morning 6, etc. Is there any out of the box .NET API that will help me do this? I know I can do this using the Scheduled tasks, but is there any way to do this programmatically? My first response is to question why a service? But more importantly, the question would be why not use the powerful scheduler that is provided by the operating system? That said, a windows service is

How can I respond to a change in status for a Windows Service?

依然范特西╮ 提交于 2019-12-05 18:27:32
I wonder if there is any possible way to get or create an event for a status changed of a Windows Service. I know that the ServiceController class does not have the event, but it has the status. Is there any way that I can listen to an event? Cody Gray This is exactly what the NotifyServiceStatusChange function is intended for. The docs say that it: Enables an application to receive notification when the specified service is created or deleted or when its status changes. I'm not sure if there's an equivalent event wrapped in managed code, but this one is easy enough to get at using P/Invoke.

Python application using Twisted stops running after user logs off of Windows XP

倖福魔咒の 提交于 2019-12-05 18:05:19
I inherited a project using the Twisted Python library. The application is terminating after the user logs off of Windows XP. The Python code has been converted to an executable using bbfreeze. In addition, the bbfreeze generated executable is registered as a Windows service using the instsrv.exe and srvany.exe. I've taken a simple chat example from the Twisted website and create an executable from bbfreeze and registered it with instsrv and srvany and the same problem occurs: the executable stops running after the user logs off. I'm inclined to think that something about Windows XP and the

Log4net and windows service. What else should I do to make this work

非 Y 不嫁゛ 提交于 2019-12-05 17:58:26
Please help me, I want to run log4net on my windows service. And it is simply - mission impossible. First of all, with Win forms - work great. Here is what I do with windows service: Add to assembly: [assembly: log4net.Config.XmlConfigurator(Watch = true)] My config: <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> </configSections> <log4net> <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender"> <param name="File" value="log-file.txt" /> <param name="AppendToFile" value="true" /> <layout type="log4net.Layout

Global handling exception in window service

南笙酒味 提交于 2019-12-05 17:36:59
I have a windows service run as a server. However, the server sometime stops immediately by an error which is un-handled. Please help me how to handle global exception. Thanks. Cody Gray It sounds to me like you're trying to solve the problem the wrong way around... When your program (or service) crashes because of an unhandled error, the solution is not to figure out where and how to "handle" all unhandled errors so that you can ignore them and continue execution. I've hashed out that view more clearly in this answer , but the short version is that when you encounter an unhandled exception,

Sql Exception: No Process Is on the Other End of the Pipe

徘徊边缘 提交于 2019-12-05 17:13:44
问题 I can not access my sql server connection from c# code. I get this error: Sql Exception: No Process Is on the Other End of the Pipe thats the connection string in my app.config: <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=BELLA\SQLEXPRESS;Initial Catalog=TLP;User Id=pascal;Password=test;Pooling=False"/> When I use windows authentication: Integrated Security=True; Then I can connect to the database. BUT I can NOT use windows authentication

How to stop worker threads in a multithreaded Windows service on service stop

早过忘川 提交于 2019-12-05 16:59:38
问题 I have a Windows service that uses the producer/consumer queue model with multiple worker threads processing tasks off a queue. These tasks can be very long running, in the order of many minutes if not hours, and do not involve loops . My question is about the best way to handle the service stop to gracefully end processing on these worker threads. I have read in another SO question that using thread.Abort() is a sign of bad design, but it seems that the service OnStop() method is only given

A connection attempt failed because the connected party did not properly respond after a period of time or connected host has failed to respond

坚强是说给别人听的谎言 提交于 2019-12-05 16:46:57
I'm developing a windows service, that downloads images from a specific URL. The service runs correctly on my computer but when I install it in the server it does not download the image and it gives the following error: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 212.100.220.117:80 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,

Using RegisterDeviceNotification in a .NET app

徘徊边缘 提交于 2019-12-05 16:23:23
I have seen some examples on how to use RegisterDeviceNotification from the Windows API, but I have not seen any .NET examples. I want to write a C# app that is notified when a new drive appears (specifically through USB, firewire, etc). This app needs to be a Windows service, so I can't use WM_DEVICECHANGE messages without some bad-practice hacking. I'd like to avoid that. Can anyone give me a sample of how to use RegisterDeviceNotification in C#, or at least give me a good alternative to it? EDIT: Again, this is a Windows service that has no graphical user interface. So the possible