我试图在Topshelf中自我托管ServiceStack,但一直收到错误:
只有以' /'结尾的Uri前缀是允许的。
使用ServiceStack模板进行Windows服务但不是Topshelf。
我的Apphost.cs看起来像这样:
public class AppHost : AppHostHttpListenerBase
{
public AppHost(): base("My test", typeof(MyServices).Assembly) { }
public override void Configure(Container container) { }
}
然后像这样使用它:(感谢https://gist.github.com/miketrebilcock)
public static void Main(string[] args)
{
var appSettings = new AppSettings();
AppConfig config = new AppConfig(appSettings);
HostFactory.Run(x => {
x.UseLog4Net();
x.Service<AppHost>(s => {
s.ConstructUsing(name => new AppHost());
s.WhenStarted(ah => { ah.Init(); ah.Start(config.hostname); });
s.WhenStopped(ah => ah.Stop());
});
x.RunAsLocalSystem();
x.SetDescription("My App Description (" + config.appURL + ")");
x.SetDisplayName("My App Name");
x.SetServiceName("MyApp");
x.StartAutomatically();
});
}
有什么建议吗?