Note that there are some explanatory texts on larger screens.

plurals
  1. POInstalling the console application as a Windows service
    primarykey
    data
    text
    <p>I'm writing a simple Windows Service based on <a href="http://topshelf-project.com" rel="nofollow noreferrer">TopShelf</a>. How to install my application as a service? I tried to execute <code>SpyService.exe install</code>, but it doesn't work.</p> <p>What is the difference between next two ways of configuring the service?</p> <pre><code>var cfg = RunnerConfigurator.New( x =&gt; { x.ConfigureService&lt;SpyService&gt;(s =&gt; { s.Named("SpyService"); s.HowToBuildService(name =&gt; new SpyService()); s.WhenStarted(tc =&gt; { XmlConfigurator.ConfigureAndWatch(new FileInfo(".\\log4net.config")); tc.Start(); }); s.WhenStopped(tc =&gt; tc.Stop()); }); x.RunAsFromInteractive(); x.SetDescription("Сервис логирования действий пользователя."); x.SetDisplayName("SpyService"); x.SetServiceName("SpyService"); }); Runner.Host(cfg, args); </code></pre> <p>and</p> <pre><code>var host = HostFactory.New(x =&gt; { x.Service&lt;SpyService&gt;(s =&gt; { s.SetServiceName("SpyService"); s.ConstructUsing(name =&gt; new SpyService()); s.WhenStarted(service =&gt; { XmlConfigurator.ConfigureAndWatch(new FileInfo(".\\log4net.config")); service.Start(); }); s.WhenStopped(service =&gt; service.Stop()); }); x.RunAsLocalSystem(); x.SetDescription("Сервис логирования действий пользователя."); x.SetDisplayName("SpyService"); x.SetServiceName("SpyService"); }); host.Run(); </code></pre> <p>I noticed that if I use the second method the service is successfully installed, but there is not possible to start the service with <code>x.RunAsFromInteractive()</code> as in first way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload