Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9070615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:43:34+00:00 2026-06-16T17:43:34+00:00

I am facing a problem of cyclic dependency when creating the following MVP design

  • 0

I am facing a problem of cyclic dependency when creating the following MVP design (for winforms) using windsor container.

My presenter depends on the view and model:

ConcretePresenter(IView view, IModel model)
{
    this.view = view;
    this.model = model;
}

My view depends on the presenter:

ConcreteView(ConcretePresenter presenter)
{
    //actual requirement that the presenter use the current instance of the view and a model object 
    //new presenter(this, new model()) 
    this.presenter = presenter;
}

I am registering all components using Windsor castle (in a separate composition root class) as below:

IWindsorContainer container;
container = new WindsorContainer();
container.Register(Component.For<ConcretePresenter>().ImplementedBy<ConcretePresenter>());
container.Register(Component.For<IModel>().ImplementedBy<ConcreteModel>());                      
container.Register(Component.For<IView>().ImplementedBy<ConcreteView>()); 

Resolving the View brings up the issue of cyclic reference issue:

container.Resolve<ConcreteView>(); //doesn't resolve because of cyclic dependency

A possible solution would be to remove the constructor injection from the view and resolve the presenter separately.
But this causes me to use the container in two places which i was not looking to do and probably is wrong.

ConcreteView()
{
    container.Resolve<ConcretePresenter>(); //resolving at 2 different points       
}

Is there any better solution to this. Am I doing something wrong in MVP itself?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:43:36+00:00Added an answer on June 16, 2026 at 5:43 pm

    There are several solutions to this problem, but all of them break the dependency cycle by removing either the presenter or the view from as constructor dependency.

    The easiest solution would be by introducing the view as property on the presenter:

    // Presenter
    ConcretePresenter(IModel model)
    {
        this.model = model;
    }
    
    public IView View { get; set; }
    
    // View
    ConcreteView(ConcretePresenter presenter)
    {
        this.presenter = presenter;
        this.presenter.View = this;
    }
    

    Downside of this is that you need to configure each presenter as it is injected into the view, so you could also move this to a base class:

    // View
    ConcreteView(ConcretePresenter presenter) : base(presenter)
    {
    }
    
    BaseView(IPresenter presenter)
    {
        Contract.Requires(presenter != null);
        presenter.View = this;
        this.Presenter = presenter;
    }
    

    Another option is to inject a presenter factory into the view and request it from there:

    // View
    ConcreteView(IPresenterFactory factory)
    {
        this.presenter = factory.CreatePresenterFor(this);
    }
    

    Downside is that this constructor calls a factory, which is not the cleanest thing to do, but manageable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

iam facing problem in passing array to view. this is my controller code.. function
I am facing problem with UIPanGestureRecognizer. suppose i am adding 10 button dynamicaly using
I am facing problem using float in loop its value stuck at 8388608.00 int
I am facing problem while uploading a file with larger size. I am using
I am facing problem while creating sign-up portlet in Liferay 6.1 and store user
Well i am not using email verification so i am facing problem in checking
Hi I am facing problem with the following scenarios 1) I have a common
Facing problem for generating SQL Server Query In the Following query dynamic conditions are
I am facing problem in big decimal no. Following code snippet will explain my
I'm facing problem in putting cross button on top of the textview. I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.