为什么我的Topshelf服务没有启动?

时间:2011-06-27 09:10:52

标签: topshelf

我遇到了搁置Topshelf服务的问题,该服务在应该启动时无法启动:即使搁架文件夹发生更改,并且Topshelf注意到这一点,该服务也未启动。没有显示任何错误消息(实际上没有任何日志消息),我真的不知道从哪里开始寻找问题。

这就是我所拥有的:

  • 我已在日志中验证Topshelf注意到文件夹C:\Topshelf.Host\Services\MyService\中的更改。

  • 我已验证Topshelf货架文件夹中的文件名是MyAssembly.dllMyAssembly.configMyAssemblyMyService相同,即使是大小写也匹配。

  • 我的配置文件中包含以下内容:

    <configSections>
      <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
      <section name="ShelfConfiguration" type="Topshelf.Shelving.ShelfConfiguration, TopShelf" />
    </configSections>
    
    <ShelfConfiguration Bootstrapper="MyNamespace.MyBootstrapper, MyAssembly" />
    
    ...
    
  • 我在MyAssembly.dll中有以下课程:

    namespace MyNamespace
    {
        public class MyBootstrapper : Bootstrapper<MyService>
        {
            public void InitializeHostedService(IServiceConfigurator<MyService> cfg)
            {
                cfg.HowToBuildService(name => new MyService());
                cfg.WhenStarted(s => s.StartService());
                cfg.WhenStopped(s => s.StopService());
            }
        }
    
    
        public class MyService
        {
            public void StartService()
            { 
                ...
            }
            public void StopService()
            { 
                ...
            }
        }
    }
    

1 个答案:

答案 0 :(得分:3)

事实证明我在问题中包含的所有内容确实都已正确设置,但我在配置文件的其他位置发生了拼写错误,在加载我的服务时给了Topshelf带来了麻烦。当我纠正这些时,一切都按预期工作。

我正在结束这个问题,因为问题不在这里。