windows-services

Exception handling best practice in a windows service?

五迷三道 提交于 2019-12-04 23:51:37
I am currently writing a windows service that runs entirely in the background and does something every day. My idea is that the service should be very stable so if something goes wrong it should not stop but try it next day again and of course log the exception. Can you suggest me any best practice how to make truly stable windows services? I have read the article of Scott Hanselman of exception handling best practice where he writes that there are only few cases when you should swallow an exception. I think somehow that windows service is one of the few cases, but I would be happy to get some

Do you need to re-install a Windows service after rebuilding

守給你的承諾、 提交于 2019-12-04 23:13:26
If I rebuild a Windows Service after making changes, can I just copy and replace the old assembly / .exe files to get those changes to run or do I need to re-install the service? Also do I have to first uninstall the service before installing the new version? You don't have to uninstall and reinstall the service since this only adds registry info regarding the executable path and launch options. Just stop the service, copy your assemblies and restart it You do not need to uninstall the service just make changes in your files after stopping the service and then start again it will consider your

Serilog in Windows-Service not writing to logfile

十年热恋 提交于 2019-12-04 22:50:27
I am using Serilog within an TopShelf Service, logging to the console and a rolling file. When running the service in a console my messages are written to the logfile, but when I install the service and run it no logging occurs. Is there anything special I need to configure? The file is written to the binaries folder under ".\logs\log-{date}.txt". Best regards Gope I had a very similar issue. In my case the problem was with relative paths. I just had to specify absolute path. Now it works like a charm. WriteTo.RollingFile(AppDomain.CurrentDomain.BaseDirectory + "\\logs\\log-{Date}.log") Hope

Multiple Instances of same Application as a Windows Service?

爱⌒轻易说出口 提交于 2019-12-04 21:44:26
问题 I have an application that manages the heavy processing for my project, and need to convert it to a "Windows Service." I need to allow running multiple versions instances of the application processing, which seems to be a fairly normal requirement. I can see at least three approaches to do this: Create a single installed directory (EXE, DLLs, config) but install as multiple Services instances from it. Have a single Services instance spawn multiple instances of itself after launching, a la

Quartz Job Scheduler in Windows Service

耗尽温柔 提交于 2019-12-04 20:55:43
I have this windows service project which's OnStart method looks like this protect void OnStart(string[] args) { IScheduler someScheduler = _schedFactory.GetScheduler(); // _schedFactory is a priva field of the service class IJobDetail someJob = JobBuilder.Create<SomeJob>() .WithIdentity("SomeJob") .Build(); ITrigger someTrigger = TriggerBuilder.Create() .StartAt(new DateTimeOffset(DateTime.UtcNow.AddSeconds(30))) .WithSimpleSchedule(schedule => scheduler.WithIntervalInMinutes(3).RepeatForever()) .Build(); someScheduler.SchedulerJob(someJob, someTrigger); someScheduler.Start(); } I use Visual

Service not able to access a mapped drive

假装没事ソ 提交于 2019-12-04 20:32:28
I have read in many forums that mapped drives are not accessible from a service as no user is logged on. Question 1) I tried making my service as a log on - as some account and i had my network drive mapped in that very account. The service still cannot access it. Why? Question 2) From the same sevice, i invoke another process. Under what user account will the process run? Thanks 1) Use UNC paths instead, then you do not need access to mapped drive letters. As to why you cannot access them even when running in the same account, it is hard to say for sure without seeing your actual code. 2) it

An error in the MSDN walk-through - “How to: Host WCF in a Windows Service Using TCP”

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 19:58:28
I've been banging my head against a brick-wall the past 2 days trying to successfully use this example on MSDN: How to: Host WCF in a Windows Service Using TCP If you follow the example through and place the Consumer application within the same solution then it runs successfully - even if the service is turned off ! If the service is switched on and the consumer application is published to say a different network drive then it will not run because the WCF is not listening. The following piece of code in the walk-through is the culprit: protected override void OnStart(string[] args) { if

Fire timer_elapsed immediately from OnStart in windows service

喜夏-厌秋 提交于 2019-12-04 19:16:15
问题 I'm using a System.Timers.Timer and I've got code like the following in my OnStart method in a c# windows service. timer = new Timer(); timer.Elapsed += timer_Elapsed; timer.Enabled = true; timer.Interval = 3600000; timer.Start(); This causes the code in timer_Elapsed to be executed every hour starting from an hour after I start the service. Is there any way to get it to execute at the point at which I start the service and then every hour subsequently? The method called by timer_Elapsed

Windows Services open source framework [closed]

谁都会走 提交于 2019-12-04 19:13:33
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I was listening to a podcast a while back on an Open Source project. I can't remember what the project was called, but the guys doing it said they'd split out their Windows Service support into a separate Open Source project. Like I say, I can't remember the project or what they've called the break-out project.

WCF Service Library hosted as a Windows Service using Castle.Windsor 3.0 issue

淺唱寂寞╮ 提交于 2019-12-04 19:13:20
I am wanting to host my WCF Service Library in a windows service. Although it will be communicating to another wcfservice over a local network. I am having great difficulty in finding recent, up-to-date documentation or help to configure the solution for this purpose. Can anyone advise: a) What the preferred endpoint for this kind of connection? (The other WCF service is hosted using a basicHttpBinding) - this in itself lends itself well to configuring the Castle container through hijacking the global.asax. However, hosting this solution in a windows service means i no longer have access to a