Is TS Documentation out of date for version 4.0.3?? Delegate 'System.Func<ConsoleApplicationServer.HangfireWebServer>' does not take 1 arguments

288 views
Skip to first unread message

Raphi Levine

unread,
Dec 28, 2016, 12:08:18 PM12/28/16
to topshelf-discuss
I just installed latest version of TS (4.0.3).
I copied sample code from documentation (see below) and am getting a number of compile time errors.
I believe the main issue is this error "Delegate 'System.Func<ConsoleApplicationServer.HangfireWebServer>' does not take 1 arguments"

public class Program
    {
        static void Main(string[] args)
        {
            HostFactory.Run(x => 
            //Host host = HostFactory.New(x => 
            {
                x.Service<HangfireWebServer>(s =>
                    {
                        s.ConstructUsingName(name => new HangfireWebServer());
                        s.WhenStarted(tc => tc.Start());
                        s.WhenStopped(tc => tc.Stop());
                    });
                x.RunAsLocalSystem();
 
                x.SetDescription("A job queue manager built on top of Hangfire");
                x.SetDisplayName("Job Queue (Hangfire)");
                x.SetServiceName("JobQueue");
            });
        }
    }

I believe the issue maybe that the ConstructUsingName method of the HostConfigurator is not longer available (deprecated??).  If I comment out that line, I can compile the service, however I get a run time error which says:

Topshelf.HostFactory Error: 0 : The service terminated abnormally, Topshelf.HostConfigurationException: The service was not properly configured: 
[Failure] Factory must not be null
   at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results)
   at Topshelf.ServiceExtensions.<>c__DisplayClass7_0`1.<CreateServiceBuilderFactory>b__0(HostSettings x)
   at Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost()
   at Topshelf.HostFactory.New(Action`1 configureCallback)
   at Topshelf.HostFactory.Run(Action`1 configureCallback)
 
I am not able to find any documentation which works.  (Seems that the documentation here https://topshelf.readthedocs.io/en/latest/configuration/quickstart.html has not been updated (I noticed that the documentation says that it was tested with .Net 4.0 and it can only be installed with 4.5.2.

All help and sample code to work with 4.0.3 will be much appreciated.

Raphi Levine

unread,
Dec 28, 2016, 12:32:50 PM12/28/16
to topshelf-discuss
Nevermind this question.  I just realized that I am using a method name of ConstructUsingName instead of ConstructUsing.  Duhhhh,.,.
It is a bit funny that the ConstructUsing does not show up in the Intellisense in VS 2013.
At least now I can compile.  :)
Reply all
Reply to author
Forward
0 new messages