topshelf

Serilog in Windows-Service not writing to logfile

不问归期 提交于 2020-01-13 07:32:06
问题 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 回答1: I had a very similar issue. In my case the problem was with relative paths. I just had to specify absolute path. Now it

Topshelf exception

左心房为你撑大大i 提交于 2020-01-04 04:32:46
问题 I'm using topshelf and I'm getting this exception when I try to use the "-i" option to install as a service. Unable to cast object of type 'Magnum.CommandLineParser.SwitchElement' to type 'Magnum.CommandLineParser.IArgumentElement'. Exception occurs in this function static void Set(TopshelfArguments args, IEnumerable<ICommandLineElement> commandLineElements) { var command = commandLineElements .Take(1) .Select(x => (IArgumentElement) x) //EXCEPTION BREAKS ON THIS LINE .Select(x => x.Id)

CustomAction in Wix not executing

我们两清 提交于 2020-01-01 10:17:06
问题 So I'm creating my first Wix project and I seem to be having a problem executing a custom action. I'm not sure that it's being included in the msi and I'm not quite sure what I'm doing wrong. The following is my Wix file: <?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="*" Name="ExactaDynamicManifest" Language="1033" Version="1.0.0.0" Manufacturer="Bastian Software Solutions" UpgradeCode="274ff2d9-e291-4706-a8db-ce80ccd91538"> <Package

How to detect if Topshelf is running in console mode

你离开我真会死。 提交于 2020-01-01 08:38:56
问题 I am using Topshelf combined with FluentSchedule for a Windows Service. However, I want to be able to trial-run the application to simply start up and not execute the FluentSchedule code that sets up the timer etc. Is there a way when running the exe file from the Command Line (i.e. without 'install' command) to check from TopShelf that it is running in Console mode? 回答1: It's sort of a hack, but you can try to cast the HostControl interface to ConsoleRunHost , and if it's that type, you're

How to specify command line options for service in TopShelf

拜拜、爱过 提交于 2019-12-30 08:20:08
问题 I am using command line arguments to pass some configuration to the windows service (it will be few instances with different command lines). My code looks like this: HostFactory.Run(x => { x.Service<MyHost>(s => { s.ConstructUsing(name => new MyHost()); s.WhenStarted(tc => tc.Start()); s.WhenStopped(tc => tc.Stop()); }); x.AddCommandLineDefinition("sqlserver", v => sqlInstance = v); }); When I install service I use: myhost.exe install -sqlserver:someinstance Unfortunately, sqlserver command

How to catch exception and stop Topshelf service?

本秂侑毒 提交于 2019-12-30 02:47:08
问题 I have a topshelf windows service where I want to do some checking (i.e. if an xml file exists) and if the check fails I need the windows service to stop. So I tried doing the check in the Start() method and then raise an exception: public void Start() { if (!File.Exists(_xmlFile) throw new FileNotFoundException(); // Do some work here if xml file exists. } However, the windows service stays around as a process after the exception which I then have to kill manually in the task manager. Is

How can I use CommandLine Arguments that is not recognized by TopShelf?

≯℡__Kan透↙ 提交于 2019-12-29 05:46:18
问题 I want to pass some custom arguments to the console app when I install and start it as a Windows Service via TopShelf. When I use: MyService install start /fooBar: Test Console application fails: [Failure] Command Line An unknown command-line option was found: DEFINE: fooBar = Test Question: How can I make my arguments to be recognizable by TopShelf so that I can consume their values? 回答1: EDIT: This only works when running the .exe, not when running as a service. As an alternative you could

Topshelf installer requires me to press enter twice - why?

烂漫一生 提交于 2019-12-25 01:56:22
问题 When installing af service through cmd.exe the installer requires interaction with the command prompt. Twice i have to press a key to get it to continue. This is a problem for me when I want to automate the install. c:\>MyService.exe install Configuration Result: [Success] Name SFTP_Service [Success] DisplayName SFTP Service [Success] Description SFTP Service [Success] ServiceName SFTP_Service Topshelf v3.1.118.0, .NET Framework v4.0.30319.17929 Running a transacted installation. Beginning

Topshelf and .net core under linux

半城伤御伤魂 提交于 2019-12-24 20:15:03
问题 I have a simple application that starts service using topshelf and it looks simple: HostFactory.Run(x => { x.Service<RequestService>(); x.RunAsLocalSystem(); }); Well it works, but under windows when i tried this under linux I am getting: Topshelf.Runtime.Windows.WindowsHostEnvironment Error: 0 : Unable to get parent process (ignored), System.DllNotFoundException: Unable to load shared library 'kernel32.dll' or one of its dependencies. In order to help diagnose loading problems, consider

When installing a Generic Host as a service in NServiceBus, how do I provide valid credentials?

a 夏天 提交于 2019-12-23 21:06:01
问题 Imagine I create a .bat file in the following directory: \trunk\Samples\PubSub\ @ECHO OFF ECHO installing Subscriber 1 Subscriber1\bin\Debug\NServiceBus.Host.exe /install pause ECHO installing Subscriber 2 Subscriber2\bin\Debug\NServiceBus.Host.exe /install pause ECHO starting Subscriber services net start Subscriber1.EndPointConfig_v1.0.0.0 net start Subscriber2.EndPointConfig_v1.0.0.0 pause I get prompted for a username and password, but using my own credentials I get an exception as