Reputation: 31
My solution has two project: Lib project => .Net standard 2.0, with TestApp class implement AppHostBase
Host project => .Net Core 2.0. With program class like below:
var listeningOn = args.Length == 0 ? "http://*:1337/" : args[0];
var appHost = new TestApp();
appHost.Start(listeningOn);
Console.WriteLine("AppHost Created at {0}, listening on {1}",
DateTime.Now, listeningOn);
Console.ReadKey();
When I try to run it has an exception: System.NotImplementedException: 'Start(listeningAtUrlBase) is not supported by this AppHost'
Please help!
Upvotes: 2
Views: 1403
Reputation: 143339
We recommend starting from one of the .NET Core Project Templates which shows the proper way to configure ServiceStack in a .NET Core project, e.g. you can create a minimal .NET Core SelfHost with:
$ dotnet tool install -g web
$ web new selfhost ProjectName
If you're creating an empty ASP.NET Core Web App you should instead use:
$ web new web ProjectName
The recommended way to configure ServiceStack is to register your AppHost with .NET Core's pipeline like any other .NET Core middleware:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseServiceStack(new AppHost {
AppSettings = new NetCoreAppSettings(Configuration)
});
}
This is the recommended way to integrate ServiceStack with your .NET Core App which requires your AppHost
to inherit from AppHostBase
:
public class AppHost : AppHostBase { ... }
When inheriting from AppHostBase
you're never calling .Start()
on ServiceStack's AppHost, it's instead started as a normal .NET Core App using WebHostBuilder.
To support enabling source-code compatible AppHost for .NET Core and .NET Framework Integration Tests your AppHost can inherit AppSelfHostBase
in the ServiceStack.Kestrel NuGet package which is started like a normal ServiceStack Self AppHost, but as this offers less flexibility in configuring your .NET Core App, it's the less recommended configuration.
Upvotes: 3