windows-services

Converting Console app to Windows Service

自作多情 提交于 2020-08-24 08:19:43
问题 Am trying to convert my console application, which generates pdf reports, into a windows service. My code is as follows. Am I on the right direction? I installed this service and start/stop works fine but no report is generated! The console app alone works fine to generate Output.pdf. My aim is to Generate ouput when the service starts. class Program : ServiceBase { public Program() { this.ServiceName = "My PdfGeneration"; } static void Main(string[] args) { ServiceBase.Run(new Program()); }

example code: A service calls CreateProcessAsUser() I want the process to run in the user's session, not session 0

江枫思渺然 提交于 2020-08-22 12:15:40
问题 I am seeking example code: For a service calls CreateProcessAsUser() I want the process to run in the user's session, not session 0 thus far the created process is only running like a service in session 0 回答1: This was stripped from some old code that launched a console app from a service. It worked under NT4 but I haven't tested it with a modern version of Windows so can't guarantee it will work as it did on NT4. EDIT: No, that's not going to work as-is. You need to add the code found here

example code: A service calls CreateProcessAsUser() I want the process to run in the user's session, not session 0

Deadly 提交于 2020-08-22 12:15:03
问题 I am seeking example code: For a service calls CreateProcessAsUser() I want the process to run in the user's session, not session 0 thus far the created process is only running like a service in session 0 回答1: This was stripped from some old code that launched a console app from a service. It worked under NT4 but I haven't tested it with a modern version of Windows so can't guarantee it will work as it did on NT4. EDIT: No, that's not going to work as-is. You need to add the code found here

C# windows service - expose web interface

天涯浪子 提交于 2020-07-10 09:19:26
问题 I have created a web service that exposes web interface. the service run in console mode and i see the web interface public ServiceHost serviceHost = null; public ServiceHost serviceHost = null;; private readonly TestService s; public Service() { InitializeComponent(); s = new TestService(); } protected override void OnStart(string[] args) { Logger.Info("Start event"); if (serviceHost != null) { serviceHost.Close(); } // Create a ServiceHost for the CalculatorService type and // provide the

WIX service installer overrides service Installer settings

扶醉桌前 提交于 2020-07-09 12:27:05
问题 i am working on a service that is later deployed by a WIX installer. this is service installer class this.ServiceInstaller.DisplayName = "My Service"; this.ServiceInstaller.ServiceName = "MyService"; this.ServiceInstaller.ServicesDependedOn = new string[] { "ServiceA", "ServiceB", "ServiceC"}; and this is the WIX installer code <Component Id="MyService.exe" Guid="{1234}"> <File Id="MyService.exe" KeyPath="yes" Source="$system\$(sys.BUILDARCH)\MyService.exe"> <netfx:NativeImage Id="MyService

How to stop a Win32 service started with Win32::Daemon?

喜你入骨 提交于 2020-07-09 03:28:36
问题 I am able to start a Win32 service successfully on Windows 10 (Strawberry perl version 5.30.1) using the follwing script: package Win32::XYZService; use feature qw(say); use strict; use warnings; use File::Spec; use Win32; use Win32::Daemon; { die "Bad arguments" if @ARGV != 1; my $action = shift @ARGV; my $xyz = Win32::XYZService->new(); $xyz->action( $action ); } sub new { my ( $class, %args ) = @_; $args{name} = 'xyz_service2'; my ($bin, $scriptname) = Win32::GetFullPathName( $0 ); $args

Exe installation throwing error The module was expected to contain an assembly manifest .Net Core

旧时模样 提交于 2020-06-29 04:15:18
问题 I have implemented windows service using .Net Core worker service . When installing service from command prompt, getting error C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe D:\LC\WindowService\L3WorkerService.exe Microsoft (R) .NET Framework Installation utility Version 4.8.3752.0 Copyright (C) Microsoft Corporation. All rights reserved. Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///D:\LC

Exe installation throwing error The module was expected to contain an assembly manifest .Net Core

拈花ヽ惹草 提交于 2020-06-29 04:15:17
问题 I have implemented windows service using .Net Core worker service . When installing service from command prompt, getting error C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe D:\LC\WindowService\L3WorkerService.exe Microsoft (R) .NET Framework Installation utility Version 4.8.3752.0 Copyright (C) Microsoft Corporation. All rights reserved. Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///D:\LC

Equivalent of Ihostedservice in asp.net framework for background tasks

五迷三道 提交于 2020-06-24 06:27:33
问题 I have a restful micro service (web api) in .net 4.6.2 and I want to call a fire and forget function each time after certain endpoints are called to do some database cleanup work. I don' want to use Task.Run and I want to have a much reliable dedicated process to do this job. I found lot's of articles and discussions about how to use IhostedService in .net core for long running background tasks. https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container