windows-services

NotifyFilter of FileSystemWatcher not working

て烟熏妆下的殇ゞ 提交于 2020-01-01 17:42:13
问题 I have a windows service (and verified the code by creating a similar WinForms application) where the NotifyFilter doesn't work. As soon as I remove that line of code, the service works fine and I can see the event-handler fire in the WinForms application. All I'm doing is dropping a text file into the input directory for the FileSystemWatcher to kick off the watcher_FileChanged delegate. When I have the _watcher.NotifyFilter = NotifyFilters.CreationTime; in there, it doesn't work. When I

How do you register a Windows Service during installation?

徘徊边缘 提交于 2020-01-01 16:51:10
问题 I have built a windows service application in VB.net 2008, and used the Setup Wizard to add an installation process. The installer works, in that it adds the app to add/remove programs and copies all of the files etc, but it's missing the final (required) step of actually installing the service. I have added the primary output of the Project as a custom action for Install and Uninstall, without success. what's the secret? 回答1: You need to create a custom install task; MSDN has everything you

Close foreground thread gracefully on windows service stop

对着背影说爱祢 提交于 2020-01-01 15:05:23
问题 In my windows service I create one "parent" foreground thread that in turn spawns "child" threads using ThreadPool (which means they are background) to execute tasks. What is the best way to close foreground thread gracefully on windows service stop? Here is my current implementation (stripped out of task-specific logic): public partial class TaskScheduler : ServiceBase { private static AutoResetEvent _finishedTaskAutoResetEvent = new AutoResetEvent(false); //This flag is used to increase

create service on windows

北城余情 提交于 2020-01-01 07:21:12
问题 I am having trouble starting my service on my pc. My code is based on this article http://www.gamedev.net/reference/articles/article1899.asp When i call installService from my int main(int argc, char *argv[]), it is registered successfully (i can see it in msconfig and services.msc). However it has not started. I manually start the service via services.msv and i get the error "Error 2: system cannot find the file specified". Why is this? i registered the services no more then a min ago, my

Programmatically add an windows service to Windows Firewall (During Installation) [duplicate]

梦想与她 提交于 2020-01-01 06:58:06
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Programmatically add an application to Windows Firewall in my solution i have an windows service project and installer to install this service How i can add this service to Windows Firewall During Installation. 回答1: Assuming we're using a Visual Studio Installer->Setup Project - You need an installer class like this inside an assembly that's being installed, and then make sure you add a custom action for the

Which user permission does a service need to start/stop other services?

此生再无相见时 提交于 2020-01-01 05:56:45
问题 I've wrote a service that should start/stop other services. This is the code I'm using: ServiceController sc = new ServiceController("servicename"); if(sc.Status != ServiceControllerStatus.Running) { sc.Start(); } This is the callstack of the exception. (Sorry, but the message is localized in german, but that's not relevant for understanding my problem) System.InvalidOperationException: Der Dienst SCardSvr kann nicht auf dem Computer . geöffnet werden. ---> System.ComponentModel

Which user permission does a service need to start/stop other services?

≯℡__Kan透↙ 提交于 2020-01-01 05:56:08
问题 I've wrote a service that should start/stop other services. This is the code I'm using: ServiceController sc = new ServiceController("servicename"); if(sc.Status != ServiceControllerStatus.Running) { sc.Start(); } This is the callstack of the exception. (Sorry, but the message is localized in german, but that's not relevant for understanding my problem) System.InvalidOperationException: Der Dienst SCardSvr kann nicht auf dem Computer . geöffnet werden. ---> System.ComponentModel

Shared configuration files in .NET

≯℡__Kan透↙ 提交于 2020-01-01 04:53:46
问题 I have a solution that includes both a web and a Windows NT service application. These are of course two different projects but within the same solution. They do however share a lot of the same configuration. Currently I have the same values in both the web.config and the app.config file. This is starting to get messy and I'd like to have a shared configuration files for both of the applications within the solution. Is there a problem for the web application if the configuration isn't at the

SetThreadExecutionState is not working when called from windows service

六月ゝ 毕业季﹏ 提交于 2020-01-01 04:49:25
问题 I want prevent system from going to sleep/hibernate from a windows service. I am calling SetThreadExecutionState function to do that. But it seems to have no effect. I just want to know whether the function SetThreadExecutionState will for windows services. If not what will be the alternative ways to that. Below is the C# code i am using. I am calling it on Onstart method of service. [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] static extern uint

Easiest way to develop/debug a Windows service

喜夏-厌秋 提交于 2020-01-01 03:46:10
问题 I'm developing a Windows Service in VB.NET 2008, but I feel like I'm going to have an aneurysm. To debug the service, I've added a 15 second wait to the initialization code, which gives me time to start the service and attach the .NET debugger before anything happens, so I can hit breakpoints and such. I really miss "integrated" debugging with this type of workaround, and testing seems to be a huge pain. What's the best way to do "regular" debugging of a Windows Service that's in development?