0

Description of my Windsor resolving problem

I got MVC web.api project.

I use Windsor Castle for IoC. But at this moment I have a problem with resolving already registred components.

Specifically, I get this error during I am checking for potentially misconfigured components:

Some dependencies of this component could not be statically resolved. 'FoodRate.Web.DataServices.PlaceDataService' is waiting for the following dependencies: - Service 'FoodRate.Web.DataServices.PlaceMapper' which was registered but is also waiting for dependencies. 'FoodRate.Web.DataServices.PlaceMapper' is waiting for the following dependencies: - Service 'FoodRate.Web.DataServices.PlaceTypeMapper' which was registered but is also waiting for dependencies.

Some dependencies of this component could not be statically resolved. 'FoodRate.Web.DataServices.PlaceMapper' is waiting for the following dependencies: - Service 'FoodRate.Web.DataServices.PlaceTypeMapper' which was registered but is also waiting for dependencies.

I understand why DataService named PlaceDataService has to wait for its dependencies. But I do not understand why there is a problem with PlaceMapper and its dependency PlaceTypeMapper.

I checked the status of the PlaceTypeMapper resolving inside the container) and PlaceTypeMapper can be resloved without errors.

enter image description here

And as shown on the scren above the PlaceTypeMapper does not have any dependency. And status is really:

All requierd dependencies can be resolved.

Class definitions

I have attached my classes definitions:

public interface IMapper
{
}

PlaceMapper class definition:

public interface IPlaceMapper : IMapper
{
    /* ... some public definitions  */
}

public class PlaceMapper : IPlaceMapper
{
    private readonly IPlaceTypeMapper placeTypeMapper;
    private readonly IGeoLocationMapper geoLocationMapper;

    public PlaceMapper(IGeoLocationMapper geoLocationMapper, IPlaceTypeMapper placeTypeMapper)
    {
        this.geoLocationMapper = geoLocationMapper;
        this.placeTypeMapper = placeTypeMapper;
    }
    /* .... Some public methods  */
}

PlaceTypeMapper definition:

public interface IPlaceTypeMapper : IMapper
{
    /* ... Some public definitions  */
}

public class PlaceTypeMapper : IPlaceTypeMapper
{
    public PlaceTypeDto ConvertPlaceTypeToPlaceTypeDto(PlaceType placeType)
    {
                /* .... */
    }

    public IList<PlaceTypeDto> ConvertPlaceTypeToPlaceTypeDto(IList<PlaceType> placeTypes)
    {
                /* .... */
    }
}

DataService definition:

public interface IDataService
{
}

public class PlaceDataService : IPlaceDataService
{
    private readonly IUnitOfWork unitOfWork;
    private readonly IPlaceMapper placeMapper;
    private readonly IGeoLocationMapper geoLocationMapper;

    public PlaceDataService(IUnitOfWork unitOfWork, IPlaceMapper placeMapper, IGeoLocationMapper geoLocationMapper)
    {
        this.unitOfWork = unitOfWork;
        this.placeMapper = placeMapper;
        this.geoLocationMapper = geoLocationMapper;
    }

    public PlaceDto GetPlace(int id)
    {
                /* ... */
    }

    public IList<PlaceDto> GetPlaceByLocation(GeoLocationDto geoLocation)
    {
               /* ... */
    }
}

And Windsor installer section (inter alia):

container.Register(Component.For<IUnitOfWork>().
    ImplementedBy<UnitOfWork>().
    LifestyleTransient()); 

container.Register(Classes.FromThisAssembly().
    BasedOn<IMapper>().
    WithService.AllInterfaces().
    LifestyleSingleton());

container.Register(Classes.FromThisAssembly().
    BasedOn<IDataService>().
    WithService.AllInterfaces().
    LifestyleTransient());

I will be grateful for any recommendations..

Chris Schiffhauer
  • 17,102
  • 15
  • 79
  • 88
Martin Majoroš
  • 409
  • 1
  • 6
  • 17
  • take a look at http://stackoverflow.com/questions/21341636/how-can-i-tell-the-web-api-castle-windsor-routing-engine-to-use-a-different-da/21355365#21355365 – Ehsan Feb 08 '14 at 12:18
  • thanks for your comment. But i do not see anythink what could solve my problem... – Martin Majoroš Feb 08 '14 at 13:43

0 Answers0