How to register dependencies with Windsor that are in different layers of the application?

Asked

Viewed 66 times

2

How to register dependencies with Windsor that are in different layers of the application?

I don’t want to keep referencing all layers of the application in the presentation layer as most do around.

I have the following error that I know why it happens, I wonder if someone could assist to register these dependencies that are in other layers of the application without having to keep referencing everything in the presentation layer.

Can’t create 'Blognetapp.Implementation.Serviceappusuario' as it has dependencies to be satisfied.

'Blognetapp.Implementation.Serviceappusuario' is Waiting for the following dependencies: - Service 'Blognetdomain.Interfaces.Services.Iusuarioservice' which was not Registered.

I’m using C# NET MVC Windsor container.

namespace BlogNet.Windsor
{
    public class PresentationInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                Component.For<IServiceAppUsuario>().ImplementedBy<ServiceAppUsuario>(),
                Component.For<IServiceAppRole>().ImplementedBy<ServiceAppRole>(),
                Component.For<IServiceAppQuote>().ImplementedBy<ServiceAppQuote>()
                );
        }
    }
}

As I said before, it is giving error because it is not registering the dependencies that are in another layer. I don’t want to reference the other layers in the presentation layer.

  • 1

    Hello @allansud! What programming language are you using? If possible add more information to your question as lines of your code that is giving problem and everything you find useful that can help. You can do this by clicking edit

  • @Mateusdemboski I’m using . NET MVC with C#. I’m looking for someone to help me record dependency injection dependencies without referencing all layers of the project in the presentation layer.

1 answer

0


To Composition root - the place where dependencies are registered - is not part of any of the application layers. Hence the name, root.

Therefore, Composition root has (and should) reference all application components, regardless of their layers.

  • Thanks for the tip, that at least guided studies... I found something that opened the mind more. (https://stackoverflow.com/questions/15352363/composition-root-in-asp-net-mvc-ddd-application) Check it out later...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.