windows-services

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

最后都变了- 提交于 2019-11-26 19:36:51
问题 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? 回答1: OnStart should only start the work; it isn't responsible for doing it.

Error 5 : Access Denied when starting windows service

本秂侑毒 提交于 2019-11-26 19:26:18
问题 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

Upgrade a Windows Service without Uninstalling

你。 提交于 2019-11-26 19:22:59
问题 Currently I have to uninstall the old version of my service before I install the new version. I am pretty sure this has something to do with it not being smart enough to update or remove the old service entries before adding the new ones. Is there a way to have the installer skip registering the service if it already exists? (I can assume the installation folder and service name do not change between versions.) Also, is there a way to automatically stop the service when uninstalling? Edit: I

How to Start/Stop a Windows Service from an ASP.NET app - Security issues

一曲冷凌霜 提交于 2019-11-26 19:20:47
问题 Here's my Windows/.NET security stack: A Windows Service running as LocalSystem on a Windows Server 2003 box. A .NET 3.5 Website running on the same box, under "default" production server IIS settings (so probably as NETWORKSERVICE user?) On my default VS2008 DEV environment I have this one method, which gets called from the ASP.NET app, which works fine: private static void StopStartReminderService() { ServiceController svcController = new ServiceController("eTimeSheetReminderService"); if

How do i create an InstallShield LE project to install a windows service?

£可爱£侵袭症+ 提交于 2019-11-26 19:19:29
I downloaded Visual Studio 2012 yesterday when it was released on MSDN. I have noticed that a few of the project types that we had in 2010 are gone or different. The biggest difference for me right now is the removal of the Windows Installer project. Now we are being forced to use the InstallShield LE (Limited Edition). The problem here is that I write a ton of Windows Services and I can't see how to setup InstallShield LE. It appears that we (my company) will have to invest in licenses for the professional edition. Has anyone found a way to install services in InstallShield LE? When using the

The type initializer for 'MyClass' threw an exception

坚强是说给别人听的谎言 提交于 2019-11-26 18:54:20
问题 The following is my Windows service code. When I am debugging the code, I am getting the error/ exception: The type initializer for 'CSMessageUtility.CSDetails' threw an exception. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.IO; using System.Threading; using System.Windows; using System.Windows.Forms; using CSMessageUtility; namespace CS

Add nginx.exe as Windows system service (like Apache)?

时间秒杀一切 提交于 2019-11-26 18:48:38
问题 I set up NGINX as a front end server for static content and I use Apache as a back-end server for other thing. The thing is I can't find a logical answer that allows me to make nginx.exe a Windows system service (like my Apache). Any come across an answer to this? 回答1: How to do it with Windows Service Wrapper (Note: There are easier alternatives by now - see also solutions described here below using chocolatey package manager by suneg and using NSSM directly from Adamy) Download the latest

How to create an installer for a .net Windows Service using Visual Studio

我们两清 提交于 2019-11-26 18:42:47
问题 How do I create an installer for a Windows Service that I have created using Visual Studio? 回答1: In the service project do the following: In the solution explorer double click your services .cs file. It should bring up a screen that is all gray and talks about dragging stuff from the toolbox. Then right click on the gray area and select add installer. This will add an installer project file to your project. Then you will have 2 components on the design view of the ProjectInstaller.cs

Alternative to “Allow service to interact with desktop”?

你说的曾经没有我的故事 提交于 2019-11-26 18:16:06
问题 I have a windows service (C#) installed on a server that launches every 10 minutes an executable file (C#) to process some images from one directory to another. No interaction is required with any user. Nevertheless, since the executable file as an output window, to make the service run I have to enable the " Allow service to interact with desktop " checkbox which is considered as an insecure and bad practice . How would I go about this problem? I like to have the executable separated from my

How can I set up .NET UnhandledException handling in a Windows service?

谁说胖子不能爱 提交于 2019-11-26 18:14:43
问题 protected override void OnStart(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Thread.Sleep(10000); throw new Exception(); } void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { } I attached a debugger to the above code in my windows service, setting a breakpoint in CurrentDomain_UnhandledException, but it was never hit. The exception pops up saying that it is unhandled, and