Reputation: 438
I am trying to take the github ServiceStack.UseCases/ImageResizer project, and make it self hosted. I thought this would be really easy, so I referenced this: https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting but AppSelfHostBase is undefined in the project. I then tried AppHostHttpListenerBase and that got me to the point where I could at least hope to setup my self host:
public class AppHost : AppHostHttpListenerBase
{
public AppHost() : base("Image Resizer", typeof(AppHost).Assembly) {}
public override void Configure(Container container) {}
}
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
AppHost appHost = new AppHost();
appHost.Init();
appHost.Start("http://*:1301/");
}
}
I then transferred the project over to my CentOS box with mono. In monodevelop I was able to build and run, but it failed during runtime. It appears it still thinks it is an Mvc or Asp.Net project.
Aside from this attempt, I have a working self hosted ServiceStack project running there, but it is not this ImageResizer and all attempts to get my existing project to include the new project have also failed.
I also tried to include code that was part of the working self hosted project into the new one, but then symbols are undefined. Basic symbols like "ServiceStackHost". If I start trying to use Nuget and do more "Install-Package" I can solve this symbol problem, but then just cause other symbols that used to be resolved to no longer work. I don't really fully understand Nuget. Any ideas for a way forward would be appreciated.
Upvotes: 1
Views: 436
Reputation: 143369
ServiceStackHost
and AppSelfHostBase
are new classes added in ServiceStack v4.
You can use AppHostHttpListenerBase
which is a Self-hosting class in ServiceStack v3. You're looking at the v4
docs, here are the docs for ServiceStack v3 which for Self-Hosting is at:
https://github.com/ServiceStackV3/ServiceStackV3/wiki/Self-hosting
Self-Hosting apps are normally created in a Console Application where-as your example is trying to run a self-hosting app inside an ASP.NET Web Application. If you want to run ServiceStack in an ASP.NET app you should inherit AppHostBase
, otherwise if you want to run a self-hosting application, create a new Console Application and inherit from AppHostHttpListenerBase
.
Upvotes: 1