I have an API hosted with ServiceStack, connecting to a Microsoft Orleans backend.
In this example, webhooks are being delivered to ServiceStack, and then being passed on into my other Orleans application (separate executable). I have registered the IAuthRepository as follows, and can resolve this:
Component.For<IDbConnectionFactory>().UsingFactoryMethod(x => new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider)),
But when I call the CreateAuth using the following:
'ServiceStack: AppHost does not exist or has not been initialized.
Make sure you have created an AppHost and started it with 'new AppHost().Init();' in your Global.asax Application_Start() or alternative Application StartUp'
Do I really need an AppHost started in this other application? I just want to be able to create users here. I could move this up to the ServiceStack layer but other operations are happening here that need to happen together.
I seem to get strange error trying to initialize a basic AppHost:
public class EmbeddedAppHost : BasicAppHost
public override void Configure(Funq.Container container)
var connectionString = ConfigurationManager.ConnectionStrings["AppDb"].ConnectionString;
container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));
container.Register<IUserAuthRepository>(c => new CustomAuthRepository(c.Resolve<IDbConnectionFactory>()));
_appHost = new EmbeddedAppHost(); _appHost.Init();
'Could not register Request 'ServiceStack.NativeTypes.TypeLinks' with service 'ServiceStack.NativeTypes.NativeTypesService' as it has already been assigned to another service.
Each Request DTO can only be handled by 1 service.'
Note that I am not creating or referencing any other AppHost in this executable.
You can only have 1 AppHost initialized at the same time and if you don’t pass in an assembly for ServiceStack to scan for Services it will fallback to use Assembly.GetExecutingAssembly(). You could give it another assembly to scan or you could remove all plugins and prevent them registering any Services with: