windows-services

Problems with windows service, blockingcollection, and Multithreading

筅森魡賤 提交于 2019-12-10 21:09:44
问题 My scenario: Windows Service .NET 4 I poll a database for entities. When new entities come in they are added to a BlockingCollection . In the service's OnStart I create a System.Threading.Tasks.Task whose job is to enumerate the BlockingCollection (using GetConsumingEnumerable() ). The problem I'm having is this: When an unhandled exception occurs in the task, I want the exception logged and the service stopped. I can't catch exceptions from the task unless I call Task.Wait() . If I call Task

Start/Stop Window Service from ASP.NET page

爷,独闯天下 提交于 2019-12-10 21:09:19
问题 Is there a way to start / stop a windows service of a server in a different network (not \\<server name> ) from an asp.net page? I tried using ServiceController but it's only work if it's in the same network. 回答1: RE: ServiceController How to Start/Stop a Windows Service from an ASP.NET app - Security issues Anything you can do from command line or powershell can be ran from a page (assuming the app pool user has correct permissions etc) https://serverfault.com/questions/429426/how-can-i

Topshelf hosting application debugging in VS2010

孤人 提交于 2019-12-10 20:04:17
问题 I'm trying to use the Topshelf hosting application Topshelf.Host.exe to execute my .NET Class Library as a Windows service. http://topshelf-project.com/documentation/shelving/ I'm having trouble hooking up the debugger inside VS2010. Here's what I have setup Topshelf.Host.exe at say c:\projects my classlibrary service building to c:\projects\Services\library-name\ running Topshelf.Host.exe as the class library's external application to debug with With F5/run Topshelf.Host.exe is running, but

First Windows Service - timer seems not to tick

南笙酒味 提交于 2019-12-10 19:58:42
问题 I wrote my first windows service. Create WS project Rename Service Drag a timer into the middle Enable it, tick to 1s Create a logfie in tick when not exists Install the service Run the Service Nothing happens... I try to attach to the service, it's loaded correctly, but with a breakpoint in it, it never hits. Any ideas? Code Timer: private void timMain_Tick(object sender, EventArgs e) { if (!File.Exists("C:/test.txt")) File.Create("C:/test.txt"); } Code initialize: private void

How do I give my windows service admin rights

好久不见. 提交于 2019-12-10 19:46:27
问题 I have a winform that allows me to enable and disable all my 8 year old's network adapters using this code: protected override void OnStart(string[] args) { //start timer SelectQuery query = new SelectQuery("Win32_NetworkAdapter","NetConnectionStatus=2"); ManagementObjectSearcher search = new ManagementObjectSearcher(query); foreach (ManagementObject result in search.Get()) { NetworkAdapter adapter = new NetworkAdapter(result); adapter.Disable(); enabled = false; } InternetCheckTimer.Start();

How does one map network drive from windows service?

梦想与她 提交于 2019-12-10 19:07:11
问题 I'm trying to map network drive from windows service, I use batch file for executing the following command NET USE U: \\192.168.55.6\folder password While executing batch file either in service constructor or in onstart event, drive is not mapped? Process process = new Process(); process.StartInfo.FileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\MAP.BAT"; process.StartInfo.CreateNoWindow = false; process.Start(); How does one map

The Service on local computer started and then stopped ,Some services stop automatically if there are not in use by other services or programs

不羁的心 提交于 2019-12-10 17:55:01
问题 I created one sample windows service and installed my service with successfully. But while going to START the service. I am getting below error. This sevice on local computer started and then stopped. some serivces stop automatically if then are not in use by other serives or programs My config file Code: <system.serviceModel> <services> <service name="SvcClient.WCFJobsLibrary.Service1"> <endpoint address="" binding="wsHttpBinding" contract="WCFJobsLibrary.IService1"> <identity> <dns value=

Excel 2013 COM API Hangs ExportAsFixedFormat under Service Account

白昼怎懂夜的黑 提交于 2019-12-10 17:53:20
问题 I have a .NET Windows Service which calls the Excel 2013 COM API to export an excel document on PDF, I have tried this code with the Windows Service running under two different domain accounts, both local administrator on the machine running the code. Under my personal account, which I'm also logged into the machine as, the code executes as expected. Under the service account, which is an active directory account, that is not logged into the machine the excel document is opened but the export

How do I run my C# service with elevated UAC privileges on Windows 2012r2?

ε祈祈猫儿з 提交于 2019-12-10 17:31:27
问题 I have a service which requires elevated administrative permissions. The service runs fine on Windows XP and Windows 2008r2 but when I run the code which checks to see whether the application is executing under an elevated administrative context on Windows 2012r2 - the result is always false. I have already tried adding <requestedExecutionLevel level="requireAdministrator" uiAccess="true" /> to the application manifest and this works fine when I run the same code as a console application -

Powerpoint Interop fails in a Windows Service but works fine in a Windows Form application

≡放荡痞女 提交于 2019-12-10 17:16:16
问题 I've written an application to watch a folder, and whenever a PowerPoint document is dropped into it, it goes through the slides within it and generates png images of each slide. This works fine in a windows forms application but I've put exactly the same code in a windows service, used the same test file and it fails to open it with the following error: Error: PowerPoint could not open the file. at Microsoft.Office.Interop.PowerPoint.Presentations.Open(String FileName, MsoTriState ReadOnly,