Manos
Manos

Reputation: 23

Conflict on solution with two services

I've been trying to set up a solution with the following scenario:

  1. Client app X calls Service A
  2. Service A calls Class Library Y
  3. Class Library Y calls Service B

So the projects reference each other in this way:

I have configured the project to start debug all projects (except class library) and the services are running under IIS Express on different ports.

When I use SocialBootstrapApi project as template for the services and I start debugging, Service A starts fine but I get a compilation error on Service B:

CS0121: The call is ambiguous between the following methods or properties:
'ServiceStack.Mvc.Bundler.ToJsBool(bool)' and 'ServiceStack.Mvc.Bundler.ToJsBool(bool)'

on line

App.models.login.set({ isAuthenticated: @session.IsAuthenticated.ToJsBool() });

I also tested using an empty ASP.NET project + ServiceStack.Host.AspNet as template, again Service A runs but I get a

System.IO.InvalidDataException: AppHostBase.Instance has already been set

on line

new AppHost().Init();

Upvotes: 1

Views: 208

Answers (1)

jruizaranguren
jruizaranguren

Reputation: 13597

It seems that you are trying to launch a host within other working host. I would suggest you to reorder and decouple the dependencies.

You might do this by:

  • Library Y exposes an interface /contract with its own needs. No direct reference to any service is hard-coded.
  • Service B implement that interface (or library B do it).
  • Then Service A or AppX are the unique hosts that configure all services, and you hook all parts with IoC container.

I could make a better proposal if more concrete description of services, etc. are given. Servicestack let you decouple inter-services calls through the IoC container and also through IMessageService

Upvotes: 1

Related Questions