Plugin registration after AppHost initialization

Hi ServiceStack,
is it possible to register a plugin (at runtime) after invoking AppHost.Init() ?

The scenario is the following: I’ve an ASP.NET MVC hosted in IIS as a container application. My app is divided in different areas, all these area refers to the ServiceStack IoC container, so this is initialized before invoking MVC RegisterAllAreas() method. Some of these areas are also “containers” for ServiceStack services (in this case the area is a SS plugin). I need to register the plugin during the MVC area registration.

Any suggestion?


No all plugins should be registered in AppHost.Configure() and should remain immutable thereafter. Why not delay when you call AppHost.Init()? it still needs to be called on App_Start but you should be able to initialize it after MVC is initialized.

it’s quite complicated to explain but I need to preserve this order of calls.
I’ve found that I can invoke ServiceStackHost.Instance.RegisterService after AppHost.Configure() the service is exposed but ServiceStack does not consider custom routes.
For example:

public class Hello : IReturn
public string Name { get; set; }

public class HelloResponse
public string Message { get; set; }

public class HelloService : Service
public object Any(Hello request) =>
new HelloResponse
Message = $“Hello {request.Name}”

After AppHost.Configure() I’m invoking:

ServiceStackHost.Instance.RegisterService("/hello", “/hello/{Name}”);

My service is exposed only with default routes but not with custom routes (I’ve also made the attempt to decorate the request DTO with the Route attribute).

You can’t register it after AppHost.Configure() is run, collect all the Services you need to register and register them before calling appHost.Init().