Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving on a named binding #261

Closed
InlineAsm opened this issue Oct 24, 2017 · 3 comments
Closed

Resolving on a named binding #261

InlineAsm opened this issue Oct 24, 2017 · 3 comments
Assignees
Labels

Comments

@InlineAsm
Copy link

When an interface is bound to a class (named) and that class needs the same interface in it's constructor with a different name ninject throws complaining about a cyclic dependency.

This is different from the previous version of ninject which correcly resolved this,

example:

    interface IScreen
    {
        
    }

    class View1 : IScreen
    {
        private readonly IScreen _childView;

        public View1([Named("ChildView")] IScreen childView)
        {
            _childView = childView;
        }
    }

    class ChildView : IScreen
    {
        public ChildView()
        {
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var kernel = new StandardKernel();
            kernel.Bind<IScreen>().To<View1>().Named("MainView");
            kernel.Bind<IScreen>().To<ChildView>().Named("ChildView");

            var instance = kernel.Get<IScreen>("MainView"); // <-- This throws with a cyclic dependency exception
        }
    }

@scott-xu scott-xu self-assigned this Oct 24, 2017
@scott-xu scott-xu added the Bug label Oct 24, 2017
@michaelestermann
Copy link

When we updated the ninject package in our solution, we ran exactly into this issue. We've seen, that its fixed but not yet provided on nuget.
Could you please create a new package (3.3.4) containing this fix.

@scott-xu
Copy link
Member

Released @michaelestermann

@michaelestermann
Copy link

Thanks for the fast feedback. It just works now with the latest version 👍

glenkeane-94 pushed a commit to glenkeane-94/Nin-ject that referenced this issue Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants