How can I resolve circular dependencies in Funq IoC?

Posted by Rickard on Stack Overflow See other posts from Stack Overflow or by Rickard
Published on 2012-09-06T13:59:16Z Indexed on 2012/09/06 15:38 UTC
Read the original article Hit count: 473

I have two classes which I need to reference each other.

class Foo
{
    public Foo(IBar bar) {}
}

class Bar
{
    public Bar(IFoo foo) {}
}

When I do:

container.RegisterAutoWiredAs<Foo, IFoo>();
container.RegisterAutoWiredAs<Bar, IBar>();

and when I try to resolve either interface I get a circular dependency graph which results in an eternal loop. Is there an easy way to solve this in Funq or do you know of a workaround?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ioc-container