windows-services

ClickOnce deploy a Windows Service?

强颜欢笑 提交于 2019-11-27 19:58:00
Is it possible to deploy a Windows Service using ClickOnce? If so, how do you achieve this? Currently we have to use a Deployment project, and the installation process could be simplified greatly by using ClickOnce. Marc Gravell AFAIK you can't really use ClickOnce end-to-end to deploy a service; there are issues with both the file locations (ClickOnce installs into a user's profile) and installation (ClickOnce is largely side-effect free). You can, however, write a service as an exe that can self-install/uninstall from the services list, like so ; basically, you write it as as a console exe

Screen capture from windows service

我怕爱的太早我们不能终老 提交于 2019-11-27 19:56:30
I've got DirectShow based screen capture software. Internally it calls CopyScreenToBitmap function to grab screen. Then the picture is compressed by ffdshow. It works fine as a desktop application, but as window service, on certain computers it does not work (black picture). I've set 'Allow service to interact with desktop' and run that service on current user account. Any ideas what could be wrong? I test it on windows XP, but it is expected to work on Vista and 7 as well. Yes it works as desktop application on all computers, but on some of them (on majority of them) it fails as a service.

Windows Service System.Timers.Timer not firing

空扰寡人 提交于 2019-11-27 19:20:21
I have a Windows service written in C# which is meant to perform a task every few minutes. I'm using a System.Timers.Timer for this but it doesn't ever appear to fire. I've looked at many different posts here on SO and elsewhere and I'm not seeing what is wrong with my code. Here is my code, with non-timer related items removed for clarity... namespace NovaNotificationService { public partial class NovaNotificationService : ServiceBase { private System.Timers.Timer IntervalTimer; public NovaNotificationService() { InitializeComponent(); IntervalTimer = new System.Timers.Timer(60000); //

What is the proper way for a Windows service to fail?

拜拜、爱过 提交于 2019-11-27 19:18:04
I have inherited a Windows service written in C#. Under rare conditions it fails badly. However, it isn't at all clear how to fail well. Ross Bennett states the problem elegantly at bytes.com . For the sake of simplicity I will just quote him here. Ahoy, Folks! I've been looking all over for this, but I just can't seem to shake any documentation out of the MSDN or from Google. I've reviewed every .NET article on developing Windows Services in the MSDN I've located. I'm developing a Windows Service application. This service reads its configuration data from the system registry (HKLM) where it

Xps printing from windows service

浪子不回头ぞ 提交于 2019-11-27 19:11:35
I'm trying to print XPS documents from a windows service on the .net framework. Since Microsoft does not support printing by using System.Drawing.Printing nor by using System.Printing (WPF), I'm using the native XPSPrint API. This is suggested to me by Aspose in http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/howto-print-a-document-on-a-server-via-the-xpsprint-api.html . When I try to print an XPS document from a windows service, the result contains strange characters instead of the text I want. I tried with different printers (including virtual printers like for

Check status of services that run in a remote computer using C#

会有一股神秘感。 提交于 2019-11-27 19:06:39
I'm using the following code. ServiceController MyController = new ServiceController(); MyController.MachineName = server_txt.Text.Trim(); MyController.ServiceName = "Service1"; string msg = MyController.Status.ToString(); Label1.Text = msg; This code works fine for network computers where I have access. How to change this so it works for the systems in different domains using credentials? If you use WMI, you can set the credentials in 'ConnectionOptions'. ConnectionOptions op = new ConnectionOptions(); op.Username = "Domain\\Domainuser"; op.Password = "password"; ManagementScope scope = new

Windows service stops automatically

南楼画角 提交于 2019-11-27 19:02:08
I made a Window service and let it work automatically and under localsystem account, when the service starts it fires this message for me and then stops The [service name] service on local computer started and then stopped. Some Services stop automatically if they are not in use by another services or programs. What's the problem and what's the solution? Either you are not starting any threads on the OnStart method to do work, or there is an exception raised within your OnStart method. If an exception is thrown, it will appear in the Windows Event log. The Windows Event log is a good place to

Windows Services: OnStart loop - do I need to delegate?

十年热恋 提交于 2019-11-27 18:49:36
I've got a windows service which scans a folder every n seconds for changes. I'm getting "the service did not respond to the start command in a timely fashion" when trying to start it up. I've got a loop setting off in OnStart like so: public void OnStart(string[] args) { while (!_shouldExit) { //Do Stuff //Repeat Thread.Sleep(_scanIntervalMillis); } } Is this what is causing the error? Should I delegate this method? OnStart should only start the work; it isn't responsible for doing it. This typically means spawning a new thread to do the actual work. It is expected that OnStart completes

Error 5 : Access Denied when starting windows service

与世无争的帅哥 提交于 2019-11-27 18:38:45
I'm getting this error when I try to start a windows service I've created in C#: My Code so far: private ServiceHost host = null; public RightAccessHost() { InitializeComponent(); } protected override void OnStart(string[] args) { host = new ServiceHost(typeof(RightAccessWcf)); host.Open(); } protected override void OnStop() { if (host != null) host.Close(); host = null; } Update #1 I solved the issue above by granting permissions to the account NETWORK SERVICE but now I have an another problem: Update #2 Service cannot be started. System.InvalidOperationException: Service

Code for executing method every day at specific time C# (Windows Service) failed

本秂侑毒 提交于 2019-11-27 18:37:59
问题 I had this code to execute method of windows service every day at 5am: EDIT: MyService ws = new MyService (); protected override void OnStart(string[] args) { if (serviceHost != null) { serviceHost.Close(); } serviceHost = new ServiceHost(typeof(MyService)); serviceHost.Open(); double TimeOfExecution = 5; DateTime now = DateTime.Now; DateTime today5am = now.Date.AddHours(TimeOfExecution); DateTime next5am = now <= today5am ? today5am : today5am.AddDays(1); System.Threading.TimerCallback